0

I want to get page id 12 and 14 using WP-API.
Normally, if I wanted only 1 page I would write

'/wp-json/pages?filter[p]=14'

or

'/wp-json/pages?filter[page_id]=14'

If I wanted pages by author id 1 and 2, I'd write

'/wp-json/pages?filter[author]=1,2'



These all work but trying to get page 12 and 14 don't.
I tried p, page_id, post__in

I'd appreciate if anyone could shed some light. Thanks

PS.: using version 1.x of the WP-API

dnl005
  • 11
  • 1
  • 4

1 Answers1

-1

you can use the folowing example:

http://airbandb.ir/wp-json/wp/v2/job_listing?filter[post__in][]=99997199&filter[post__in][]=99997118 its work for me

before it you have to set query vars enable for your post type like this :

add_filter('rest_query_vars', 'custom_rest_query_vars');
function custom_rest_query_vars($query_vars) {
  //print_r($query_vars);exit;
  $query_vars = array_merge( $query_vars, array('job_listing_type','post__in', 'type', 'id') );
  return $query_vars;
}
Jonathan Argentiero
  • 5,687
  • 8
  • 29
  • 34
  • Could you place the url between backticks? `\`` This way it will be rendered in a code font and allows us to see it better what you added (also, indent the lines by 4 spaces to made a large code block) – Ferrybig Sep 14 '16 at 19:35