WordpressWordpress Tricks

How to Get WordPress post by Taxonomy Category id?

Views

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

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

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

Positive SSL