Retrieve REST Posts for Specific Pages

Update 18/10/2018

This is really not well documented, but I have a way that may suit your workflow better. Finding page ID’s can be a bit painful as different sites have different page ID’s. A better way might be to use the page slug. That is typically the page title in smalls, with the spaces swapped for dashes. For example, this page slug would be: –

retrieve-rest-posts-for-specific-pages

Well, you can now use this in your url, so you might have something like: –

http://www.mysite.com/wp-json/wp/v2/pages/?slug=field,monarch

Where your page slugs are field and monarch and your page titles are Field and Monarch.

Where this is useful is if you are say recreating an archive (category/tag) page. Assuming your pages are titled the same as the pages on the site serving the REST (JSON) content, you can look for slugs of pages in the categories/tag in question on your site, then list them in this URL. This will give you a feed of all content from these pages so you can reconstruct an archive page from the feed.


After a lot of research I have finally found a way to retrieve specific pages from a WordPress REST site using it’s JSON feed. I should note that this is not complicated at all, just frustratingly badly documented!

http://www.mysite.com/wp-json/wp/v2/pages?include=8,528

In this case the link would go to mysite.com and retrieve the pages with ID’s of 8 and 528 only. Very useful for doing something like related pages.

As I said it’s not rocket science, but it’s taken me a really long time to find this!

Leave a Reply

Your email address will not be published. Required fields are marked *