0

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.

  • 1
    Can you please define "posts by page" and "posts from page"? – cybmeta Apr 4 '16 at 6:11
  • Yes, i mean posts from page – Leo Apr 4 '16 at 10:12
  • 1
    Sorry 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? – cybmeta Apr 4 '16 at 10:21
  • Sorry, my bad.So, If posts from page is a post type, then how the get link will be? – Leo Apr 4 '16 at 10:28
  • "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. – cybmeta Apr 6 '16 at 11:17
1

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.

  • But how to show list of pages? – Rishabh Nov 14 '17 at 8:16
0

Try /wp-json/wp/v2/pages/<id>. Not sure if retrieving a page by name is possible using the REST API.

  • But how to show list of pages? – Rishabh Nov 14 '17 at 8:16
  • 1
    @Rishabh /wp-json/wp/v2/pages/ – Gangesh Jan 3 at 12:04
0

the correct form is:

http://domain.com/wp-json/wp/v2/pages/533

I hope I have helped.

regards

  • 533 is the page ID. Or rather the post of the page type. – Matias Báscolo May 27 '17 at 22:35
  • Thank you for your answer, but how is this different than the answer posted by @Zlatev? Also, please post answers here on WPSE in English. – Dave Romsey May 27 '17 at 23:43
  • But how to show list of pages? – Rishabh Nov 14 '17 at 8:16

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.