Home Wordpress How to Get Wordpress post by Taxonomy Category id?

How to Get Wordpress post by Taxonomy Category id?

by therichpost
0 comment
wordpress

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

You may also like

Leave a Comment

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