Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

add_query_arg OR tax_query NOT Working

$
0
0

Replies: 0

Hi, I am planing to fetch base on custom category or taxonomy correct me if I am wrong named “genre”, and this is how I do it

$arg =   get_posts( array(
        
      'post_type'  => 'comment',
      'tax_query'  => array(
        array(
            'taxonomy' => 'genre',
            'field'    =>  'id',
            'terms'    =>  13,
        )),
      'post_status'    => 'publish',
      'orderby'        => 'date',
      'order'          => 'DESC',
    
     ));

     $url    = add_query_arg( $arg , get_home_url()."/wp-json/wp/v2/comment?".$filter);

     // A standard GET request the WordPress way
     $stuff = wp_remote_get($url);

     // Get just the body of that request (if successful)
     $body = wp_remote_retrieve_body($stuff);

     // Turn the returned JSON object into a PHP object
     $posts = json_decode($body);

As you can see it is api from custom post type the main goal is to display all post through shortcode display all data from custom post type base on custom category named “genre” but it wont work please help how can I fetch data from custom post type base on category custom category.

Ex. From post type post have category name car display all only have category car

What I need is from custom post type name art display only have category name “digital” but that category was made in custom register_taxonomy

Please thank for help.


Viewing all articles
Browse latest Browse all 59525

Trending Articles