I'm using WP REST API v2 to get posts.

When I tried to open localhost/wp-json/wp/v2/posts in my browser I got json with all my posts.

I tried to open localhost/wp-json/wp/v2/posts/?category_name=uncategorized and I got the same json though all my posts assigned to specific categories.

Maybe I'm using wrong filter but I tried to open localhost/wp-json/wp/v2/media?post_parent=15 from first json and got all media on my site instead of one attached to the post

What I'm doing wrong with this?


1 Answer 1


I found answer here https://1fix.io/blog/2015/02/28/wordpress-rest-api-media/.

add_action( 'rest_api_init', 'add_filter' );
add_filter( 'query_vars', function( $query_vars ) {
$query_vars[] = 'post_parent';
return $query_vars;
  • But is this helpful for your problem with category_name topic?
    – bueltge
    Oct 8, 2015 at 9:29
  • No, it's solving only my post_parent-problem Oct 9, 2015 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.