I already get posts from categories with: http://domain.com/wp-json/wp/v2/posts?filter[category_name]=category-name but how can i retrieve content from page? - [page_name]=page-name for example but its not working. I have searched lot but cant found any solution. Thanks.
-
2Can you please define "posts by page" and "posts from page"?– cybmetaApr 4, 2016 at 6:11
-
Yes, i mean posts from page– LeoApr 4, 2016 at 10:12
-
2Sorry but that is the same you said in the question and I don't know waht you mean. "Page" in WordPress is a post type, so do you want to get posts of "page" type o what?– cybmetaApr 4, 2016 at 10:21
-
Sorry, my bad.So, If posts from page is a post type, then how the get link will be?– LeoApr 4, 2016 at 10:28
-
1"page" is a post type, but I don't know what "posts from page" is and that is what I'm asking you. What do you mean with "post from page"? Please, explain it. Do you have a "page" (created in wp-admin-> Pages menu) where you show posts and you want to get those posts? If so, that is not possible through WP REST API without custom code becasue only you can know the logic of the code used in that page to get the posts. I hope you understand that "Pages" are not a way to categorize posts. Taxonomies should be used for that. Otherwise, if you want to get posts of "page" type, use @Zlatev answer.– cybmetaApr 6, 2016 at 11:17
4 Answers
To retrieve a page by slug, just use /wp-json/wp/v2/pages/?slug=your-page-name-here
, with "your-page-name-here" obviously being the slug of your page.
Try /wp-json/wp/v2/pages/<id>
. Not sure if retrieving a page by name is possible using the REST API.
-
-
2
the correct form is:
http://example.com/wp-json/wp/v2/pages/533
I hope I have helped.
regards
-
-
1Thank you for your answer, but how is this different than the answer posted by @Zlatev? Also, please post answers here on WPSE in English. May 27, 2017 at 23:43
-
I believe you can use something like this from the API :
/wp-json/wp/v2/pages?filter[slug]=pageslug
-
1Doesn't work any more: from the FAQ What happened to the ?filter= query parameter?– RupApr 14, 2021 at 20:04