wordpressWordpress trick to check term id has parent term or child term

Hello to all, welcome to therichpost.com. In this post, I will tell you, How to Get WordPress post by Taxonomy Category id?

If you are new in wordpress then you can check my post related to WordPress.

In these day, I am busy with other programing things like Laravel, Vue and Angular.

But I can still say, WordPress is my favorite.

Here I am going to show code snippet for How to Get WordPress post by Taxonomy Category id?:


1. Here is the code and you can add into any of your wordpress them’s template:

$catid = get_term_by( 'slug', 'cat-slug', 'Taxnomyname' );
$args = array(
'posts_per_page'   => -1,
'offset'           => 0,
'tax_query'  => array(array(
'taxonomy' => 'Taxnomyname',
'field' => 'term_id',
'terms' => $catid->term_id
)),
'orderby'          => 'date',
'order'            => 'DESC',
'post_type'        => 'match',
'post_status'      => 'publish'
);
$events = get_posts( $args );

 

If you have any query related to this post, then do comment below or ask question.

Harjas

Thank you

By therichpost

Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 19, MedusaJs, Next.js, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.