2

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.

6
  • 1
    Can you please define "posts by page" and "posts from page"?
    – cybmeta
    Apr 4, 2016 at 6:11
  • Yes, i mean posts from page
    – Leo
    Apr 4, 2016 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, 2016 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, 2016 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, 2016 at 11:17

4 Answers 4

3

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.

1
  • But how to show list of pages?
    – Rishabh
    Nov 14, 2017 at 8:16
2

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

2
  • But how to show list of pages?
    – Rishabh
    Nov 14, 2017 at 8:16
  • 2
    @Rishabh /wp-json/wp/v2/pages/
    – Yatix
    Jan 3, 2019 at 12:04
1

the correct form is:

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

I hope I have helped.

regards

3
  • 533 is the page ID. Or rather the post of the page type. May 27, 2017 at 22:35
  • 1
    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. May 27, 2017 at 23:43
  • But how to show list of pages?
    – Rishabh
    Nov 14, 2017 at 8:16
0

I believe you can use something like this from the API :

/wp-json/wp/v2/pages?filter[slug]=pageslug
1

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.