Since v3.1.0, Contextual Related Posts has included support for viewing the related posts via the WordPress REST API.
The plugin registers one namespace i.e.
contextual-related-posts/v1 that can be used to retrieve the related posts for a particular post ID.
To use the latest version of the REST API you must be using:
- Contextual Related Posts 3.1+.
- WordPress 4.4+.
- Pretty permalinks in
Settings > Permalinksso that the custom endpoints are supported. Default permalinks will not work.
- You may access the API over either HTTP or HTTPS, but HTTPS is recommended where possible.
The plugin registers one namespace
contextual-related-posts/v1 and currently, there is a single endpoint available at
|id||Post ID. This is also passed as part of the path as noted above. This is mandatory|
|limit||Number of posts to retrieve. You can also use |
|post_types||Comma-separated list of post types to which the related posts belong to. Alternatively use |
|same_post_type||Only retrieve posts from the same post type as that of the post with the id as above|
|same_author||Only retrieve posts from the same author as that of the post with the id as above|
|exclude_post_ids||Comma-separated list of post IDs to exclude|
|exclude_categories||Comma-separated list of Taxonomy IDs from which posts are excluded|