Contextual Related Posts has several customization options available via the Settings page in WordPress Admin. You can access this via Settings » Related Posts.
A typical HTML output for the plugin is below. The plugin also provides you with a set of CSS classes that allow you to style your posts.
The main CSS classes are:
- crp_related: Class of the main wrapper
div - crp-style-name: An additional class for the main
divwhen a custom style is selected in the Styles tab - crp_title: Class of the
spantag for title of the post - crp_thumb: Class of the post thumbnail
imgtag - crp_excerpt: Class of the
spantag for excerpt (if enabled) - crp_author: Class of the
spantag for author (if enabled) - crp_date: Class of the
spantag for date (if enabled) - crp_related_shortcode: Additional class of the main wrapper
divwhen the related posts are displayed via a shortcode - crp_related_block: Additional class of the main wrapper
divwhen the related posts are displayed via the Gutenberg block - crp_related_widget: Additional class added to the main wrapper
divalongside crp_related when the related posts are displayed via the widget
You can add CSS styles for these classes either in the Styles tab or in your theme’s style.css. If you’re adding additional styles for a specific custom style, it is recommended to use a selector like .crp_related.crp-style-name e.g. .crp_related.crp-rounded-thumbs.
Choose the right customization point
| If you need to… | Use… |
|---|---|
| Configure built-in output options or change appearance only | The Settings page and CSS. See Styles settings. |
| Suppress or replace output before CRP queries for related posts | crp_pre_related_postsOpens in a new window |
| Keep CRP’s query results but replace the generated HTML | crp_custom_template |
| Control which posts are queried and render your own loop | CRP_Query or get_crp_posts() |
Filter hooks
crp_pre_related_postsOpens in a new window
Short-circuits the related posts rendering. Return a non-null value to replace the output entirely — the query and the default rendering are skipped. Runs for all display methods: the content filter, shortcode, widget, block, and manual calls. Contextual Related Posts Pro uses this internally to swap in the lazy load placeholder.
Parameters:
$pre(string|null) — Pre-rendered output. Defaultnull(continue with the default rendering).$args(array) — Fully parsed arguments array.$post(WP_Post) — Post object the related posts are generated for.
Returns: string|null — Return a string to use it as the output; return null to continue normally.
crp_custom_template
Use this filter to keep CRP’s related-post query and replace its default HTML. It runs after CRP retrieves the related posts and before the built-in renderer runs. Return a non-empty HTML string to replace the complete default output, including its wrapper and heading. Return the incoming $template value to use the built-in renderer; it is null by default. An empty string does not replace the output.
The filter runs for automatic content output, the shortcode, widget, native Related Posts block, and manual get_crp() or echo_crp() calls. Direct CRP_Query and get_crp_posts() calls retrieve posts without using this renderer, so render those results yourself.
Parameters:
$template(string|null) — Default return value. Initiallynull.$results(WP_Post[]|int[]) — Related posts as post objects or IDs, matching the return type ofget_crp_posts().$args(array) — Fully parsed display arguments.
Returns: string|null — Return a non-empty HTML string to replace the default output, or return $template to continue with the built-in renderer.
This example supports either post objects or IDs in $results. It escapes the link and title and allows the safe image markup generated for the thumbnail.
CRP can cache this HTML for eligible requests when HTML caching is enabled. If your markup varies by user or request context, disable HTML caching in the arguments for that display call with 'cache' => 0. This does not disable related-post ID caching, which is controlled separately by cache_posts.
PHP wrapper functions
Display::get_default_args()
Returns the full default arguments array for the related posts display — the built-in defaults merged with the saved plugin settings. Use it to build a complete $args array before calling the rendering or query functions.
Returns: array — Default arguments including all saved settings.

Contextual Related Posts CLI Overview
Efficient Content Storage and Indexing (ECSI) in Contextual Related Posts Pro and Better Search Pro