An example how to use WordPress Rest API v2

In this post I will show you two examples about how to use WordPress Rest API v2 to, for example, get a post content from your website, or any other WordPress sites.

Example 1 – How to get post content by post ID

https://yoursite.com/wp-json/wp/v2/posts?include[]=1234

Make sure you change “yoursite.com” with your actual site domain, and change the “1234” with your intended post ID that you want to get its content.

Example 2 – How to get post content by post slug name

https://yoursite.com/wp-json/wp/v2/posts?slug=your-post-slug

As mentioned before, “yoursite.com” is your target site domain and change the “your-post-slug” with your actual post slug that you want to get its content.

Leave a Reply

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