WordPress.org

Ready to get started?Download WordPress

Forums

get custome categories in WP_Quesry (2 posts)

  1. fadi.barakat
    Member
    Posted 1 year ago #

    Hi all,

    i have this query in my template $the_query = new WP_Query( array( "posts_per_page" =>6, "post_type"=>"project_post" , "paged"=>$offset , "order" => $order , "orderby" => $order_by ) );

    it fetches all the custom categories for project post, however i want it to fetch only one custom category called 'Ongoing' it has a taxonomy=project_category and tag_ID=11

    Thank you

  2. vtxyzzy
    Member
    Posted 1 year ago #

    Please try this:

    $the_query = new WP_Query( array(
                      "posts_per_page" =>6,
                      "post_type"=>"project_post" ,
                      "paged"=>$offset ,
                      "order" => $order ,
                      "orderby" => $order_by,
                      'tax_query' => array(
                         array(
                            'taxonomy' => 'project_category',
                            'field' => 'id',
                            'terms' => array(11),
                         )),
    
                      ) );

Topic Closed

This topic has been closed to new replies.

About this Topic