WPIntell

Source evidence

How to display outside loop on single.php?

YARPP – Yet Another Related Posts Plugin · support · 2025-04-11T20:26:00+00:00

mixedsentiment
highseverity
0.95relevance
9replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

4 / 32 rows with source links

12.5% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

28 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
bcw00 resolved
Hello. This is my code. I inserted it outside the loop on single.php and uploaded my custom file yarpp-template-bottom.php into my active theme. <?php if (function_exists('yarpp_related')) { yarpp_related(array( 'template' => get_stylesheet_directory() . '/yarpp-template-bottom.php', 'limit' => 4 )); } ?> However it outputs a basic ordered list of 4 related entries and is not using the custom theme YARPP file I uploaded. Any help? This topic was modified 1 year, 2 months ago by bcw00 . Found an easier solution with the shortcodes. @bcwint00 I am interested how you did it with the shortcode. Please share shortcode. thx Tobias @subscribetech It’s just basically the shortcode in a php wrapper. Here is an example. It’s saying to use the yarpp-template-photoblog (you can change that to your own template) and limited to 3 posts. In the HTML itself, it has its own wrap, so you might have to add some additional styling if you’re mixing it in with something else. https://wordpress.org/plugins/yet-another-related-posts-plugin/#installation <?php echo do_shortcode('[yarpp template="yarpp-template-photoblog" limit=3]'); ?> If you’re running outside the loop, we encourage setting reference_id <?php echo do_shortcode('[yarpp reference_id=123]'); ?> …to show content related to post 123 @bcwint00 Usage of template in your yarpp_related function example was incorrect. No need to specify the path. For example: <?php if (function_exists('yarpp_related')) { yarpp_related(array( 'template' => 'yarpp-template-photoblog', 'limit' => 4 )); } ?> Your YARPP Custom Template file must be in the active theme’s main directory in order to be recognized by YARPP. The path is hardcoded for security. 'template' => 'thumbnails', // which theme/custom template to use. Built-in ones include "list" and "thumbnails", or the name of a YARPP template file in your active theme folder starting with "yarpp-template-". Example: yarpp-template-videos or yarpp-template-videos.php @meattle Not sure what you are referring to about the path. I mentioned they can use the name of the template (assuming they have one in their custom theme folder). @bcwint00 in your original example (first post of the thread), you’re including the path by using “get_stylesheet_directory(). This was not needed. Your example (incorrect): <?php if (function_exists('yarpp_related')) { yarpp_related(array( 'template' => get_stylesheet_directory() . '/yarpp-template-bottom.php', 'limit' => 4 )); } ?> The YARPP shortcode wraps the yarpp_related function. Correct: <?php if (function_exists('yarpp_related')) { yarpp_related(array( 'template' => 'yarpp-template-bottom', 'limit' => 4 )); } ?> @meattle Ohhh yea. I see what you mean, but I had figured that part before haha. That’s why I marked it solved so I wouldn’t waste your time. @bcwint00 Yeah, got you 🙂 Just wanted to leave the correction for others who stumble upon this post.

Comments

9 shown
bcw00 2025-04-11T23:17:00+00:00

Found an easier solution with the shortcodes.

Saleswonder Support Team 2025-04-19T10:06:00+00:00

@bcwint00 I am interested how you did it with the shortcode. Please share shortcode. thx Tobias

bcw00 2025-04-19T20:39:00+00:00

@subscribetech It’s just basically the shortcode in a php wrapper. Here is an example. It’s saying to use the yarpp-template-photoblog (you can change that to your own template) and limited to 3 posts. In the HTML itself, it has its own wrap, so you might have to add some additional styling if you’re mixing it in with something else. https://wordpress.org/plugins/yet-another-related-posts-plugin/#installation <?php echo do_shortcode('[yarpp template="yarpp-template-photoblog" limit=3]'); ?>

meattle 2025-04-20T04:01:00+00:00

If you’re running outside the loop, we encourage setting reference_id <?php echo do_shortcode('[yarpp reference_id=123]'); ?> …to show content related to post 123

meattle 2025-04-20T04:17:00+00:00

@bcwint00 Usage of template in your yarpp_related function example was incorrect. No need to specify the path. For example: <?php if (function_exists('yarpp_related')) { yarpp_related(array( 'template' => 'yarpp-template-photoblog', 'limit' => 4 )); } ?> Your YARPP Custom Template file must be in the active theme’s main directory in order to be recognized by YARPP. The path is hardcoded for security. 'template' => 'thumbnails', // which theme/custom template to use. Built-in ones include "list" and "thumbnails", or the name of a YARPP template file in your active theme folder starting with "yarpp-template-". Example: yarpp-template-videos or yarpp-template-videos.php

bcw00 2025-04-20T04:24:00+00:00

@meattle Not sure what you are referring to about the path. I mentioned they can use the name of the template (assuming they have one in their custom theme folder).

meattle 2025-04-20T04:29:00+00:00

@bcwint00 in your original example (first post of the thread), you’re including the path by using “get_stylesheet_directory(). This was not needed. Your example (incorrect): <?php if (function_exists('yarpp_related')) { yarpp_related(array( 'template' => get_stylesheet_directory() . '/yarpp-template-bottom.php', 'limit' => 4 )); } ?> The YARPP shortcode wraps the yarpp_related function. Correct: <?php if (function_exists('yarpp_related')) { yarpp_related(array( 'template' => 'yarpp-template-bottom', 'limit' => 4 )); } ?>

bcw00 2025-04-20T04:31:00+00:00

@meattle Ohhh yea. I see what you mean, but I had figured that part before haha. That’s why I marked it solved so I wouldn’t waste your time.

meattle 2025-04-20T04:33:00+00:00

@bcwint00 Yeah, got you 🙂 Just wanted to leave the correction for others who stumble upon this post.