Same question here. Now I’m using:
if(function_exists('related_posts')) {
related_posts();
}
But it looks like yarpp_related needs parameters.
Hi @gatta2 and @cnxsoft, sorry for the delay in replying over the weekend.
Yes you should switch to using yarpp_related() instead. The old function wasn’t “namespaced” so it was more likely to conflict with another plugin and cause an error.
The old related_posts() literally only fetched posts, not pages or other post types, even if you provided the “post_type” parameter to it, and even if you checked “Display results from all post types” on the YARPP settings page. So it was a bit quirky.
yarpp_related(), on the other hand, will use the setting “Display results from all post types” from the YARPP settings page. So if that is checked, yarpp_related() will look for related posts, pages, and other post types; but if it isn’t, yarpp_related() will look for posts of the *same* post type as what’s being displayed (ie, it will look for related posts when viewing a post, related pages when viewing a page, etc).
Usually this is how you would want YARPP to behave.
So you don’t have to provide any parameters to yarpp_related(), and can use it as a straight replacement for related_posts(), related_pages(), and related_entries().
But if you need to specify the type post of posts you want to receive, you can do
yarpp_related(array('post_type' => 'post')); to always get posts (even when viewing a page or other post type, and despite whatever you saved on the YARPP settings page).
Does that make sense and help?
Thank you Michael. I’ve just updated my code and the plugin, and it works fine.
Ok great, I’m going to close this issue then. It was a good question.