Goal
Add a copy-and-paste example showing how to replace Contextual Related Posts default markup with the crp_custom_template filter while leaving CRP responsible for matching and selecting the related posts.
Existing coverage
crp-api-example.php renders a direct CRP_Query loop, and crp-add-categories.php changes one list item. Neither demonstrates full output replacement through crp_custom_template.
Deliverables
- Add
contextual-related-posts/crp-custom-template.php or an equally clear filename under the display category.
- Register a uniquely prefixed callback on
crp_custom_template and document $results as related post IDs and $args as the parsed display arguments.
- Render a small accessible wrapper and list with escaped permalinks, titles, and optional thumbnails, without assuming a particular theme.
- Return a non-empty HTML string when taking over the output and return
null when the default renderer should continue.
- Add a matching Markdown companion under
src/content/snippets/contextual-related-posts/ with installation guidance, requiresPro: false, and the hook reference.
- Explain that the filter applies to automatic output and explicit display methods such as the shortcode, widget, block, and manual calls.
- Include the caching caveat: returned custom HTML is cached when CRP HTML output caching is enabled, so request- or user-specific markup needs caching disabled for that call.
This is a reusable renderer example, not a YARPP-compatible yarpp-template-*.php filesystem mechanism. The CRP API documentation update is tracked separately in contextual-related-posts#229.
Goal
Add a copy-and-paste example showing how to replace Contextual Related Posts default markup with the
crp_custom_templatefilter while leaving CRP responsible for matching and selecting the related posts.Existing coverage
crp-api-example.phprenders a directCRP_Queryloop, andcrp-add-categories.phpchanges one list item. Neither demonstrates full output replacement throughcrp_custom_template.Deliverables
contextual-related-posts/crp-custom-template.phpor an equally clear filename under thedisplaycategory.crp_custom_templateand document$resultsas related post IDs and$argsas the parsed display arguments.nullwhen the default renderer should continue.src/content/snippets/contextual-related-posts/with installation guidance,requiresPro: false, and the hook reference.This is a reusable renderer example, not a YARPP-compatible
yarpp-template-*.phpfilesystem mechanism. The CRP API documentation update is tracked separately in contextual-related-posts#229.