Yarpp does not work with divi5
-
Issue Summary
When attempting to render YARPP (Yet Another Related Posts Plugin) results inside a Divi 5 Theme Builder template, the related posts query is not displayed, even though YARPP successfully returns related results when invoked inside post content. Technical Details
- Environment:
- WordPress (latest stable)
- Divi 5 (public alpha, Theme Builder templates)
- YARPP 5.30.11
- Behavior:
- When inserting
[yarpp]inside post content, related posts render correctly. - When inserting
[yarpp]oryarpp_related()inside a Divi 5 Theme Builder template (outside ofthe_content()), the output consistently shows “No related posts found.”
- When inserting
- Debugging performed:
- Verified that
yarpp_get_related()returns a booleanfalseinstead of aWP_Queryobject when called from a Divi 5 template context. - Confirmed that YARPP’s SQL queries run successfully and that related posts exist in the database.
- Verified that the Divi 5 template is active and executing by inserting test text/PHP in the same location.
- This indicates the failure occurs not at the query level, but at the context detection layer.
- Verified that
Analysis
YARPP appears to depend on global state (
$postand/orin_the_loop) to resolve the current post ID when building the related posts query. In Divi 5, Theme Builder templates render content through a React/PHP bridge rather than the legacythe_contentpipeline, meaning these globals are not set as expected.Thus:
- Inside post content → YARPP works (globals available).
- Inside Divi 5 templates → YARPP fails (globals unavailable, returns boolean).
Impact
- YARPP is currently not compatible with Divi 5 Theme Builder templates.
- Any attempt to display related posts outside of
the_content()results in “No related posts found,” even if related posts exist. - This breaks expected functionality for sites upgrading to Divi 5 that rely on YARPP in templates.
Suggested Resolution
- Update YARPP to accept an explicit post ID parameter (e.g.,
yarpp_get_related( $post_id )) without requiring global state. - Ensure shortcode and function calls respect passed
post_idvalues when Divi (or other block/template systems) do not expose global$post. - Alternatively, Divi 5 could provide a compatibility shim that sets
$postwhen rendering templates, but ideally YARPP should not rely solely on globals in modern WP contexts.
- Environment:
The topic ‘Yarpp does not work with divi5’ is closed to new replies.