Contextual Related Posts v3.0.0 introduced CRP_Query, which works as a wrapper for WP_QueryOpens in a new window. This brings all the power and flexibility of WP_Query to Contextual Related Posts. If you’re not familiar with WP_Query, I recommend reading docsOpens in a new window.
Standard Loop
get_crp_posts()
get_crp_posts() is a wrapper for CRP_Query and can be used to retrieve an array of related posts. It also accepts the same $args as CRP_Query.
Parameters
In addition to the WP_Query parametersOpens in a new window, CRP_Query also takes these additional parameters.
$args
(array) (Optional) Arguments to retrieve posts. See Settings::get_registered_settings() for all available arguments.
- ‘post_id’ (int) Get related posts for a specific post ID or WP_Post object. If you are using CRP_Query or get_crp_posts() outside the loop, you will need to pass this, or you might get errors when fetching related posts.
- ‘include_cat_ids’ (array|string) An array or comma-separated string of category IDs. This should be the term_taxonomy_id.
- ‘include_post_ids’ (array|string) An array or comma-separated string of post IDs.
- ‘offset’ (int) number of posts to displace or pass over. Setting the offset parameter overrides/ignores the paged parameter, breaking pagination. The
'offset'parameter is ignored when'posts_per_page'=>-1(show all posts) is used.





