WordPress Post Detail API

User
post detail rest api url worpdress
Assistant
To get the post details through the REST API in WordPress, you can use the following URL structure:

### Base URL:

http://yourwebsite.com/wp-json/wp/v2/posts/{id}

### Explanation:
– Replace `yourwebsite.com` with the domain name of your WordPress site.
– Replace `{id}` with the ID of the post whose details you want to fetch.

### Example:
If your website is `example.com` and the post ID is `123`, the URL would be:

http://example.com/wp-json/wp/v2/posts/123

### Response:
A typical JSON response will include details like:
– `id`: The ID of the post.
– `title`: The title of the post.
– `content`: The content of the post.
– `excerpt`: The excerpt of the post.
– `date`: The published date of the post.
– `link`: The permalink of the post.
– `featured_media`: ID of the featured image.
– And more.

### Notes:
1. **Authentication**: Public posts are accessible without authentication, but for private or protected posts, you need to authenticate using basic authentication, cookies, or OAuth.
2. **Custom Post Types**: If you are working with a custom post type, replace `posts` with the custom post type slug, e.g., `wp-json/wp/v2/{custom_post_type_slug}/{id}`.
3. **WPML**: If you are using WPML, ensure to include the language parameter (`?lang=en`) if necessary.

Let me know if you need further assistance! ๐Ÿ˜Š

Leave a Comment

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