Thread Starter
bcw00
(@bcwint00)
Found an easier solution with the shortcodes.
@bcwint00 I am interested how you did it with the shortcode.
Please share shortcode. thx Tobias
Thread Starter
bcw00
(@bcwint00)
@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 templatein 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
Thread Starter
bcw00
(@bcwint00)
@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
));
}
?>
Thread Starter
bcw00
(@bcwint00)
@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.