• Resolved gatta2

    (@gatta2)


    I saw in changelog:
    Deprecated: functions related_posts, related_pages, related_entries (use yarpp_related instead), and related_posts_exist, related_pages_exist and related_entries_exist (use yarpp_related_exist instead)

    We are using related_posts(); in our template. Does it mean we need to change to yarpp_related();?

Viewing 4 replies - 1 through 4 (of 4 total)
  • cnxsoft

    (@cnxsoft)

    Same question here. Now I’m using:

       if(function_exists('related_posts')) {
               related_posts();
        }
    

    But it looks like yarpp_related needs parameters.

    Plugin Support Michael Nelson

    (@mnelson4)

    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?

    cnxsoft

    (@cnxsoft)

    Thank you Michael. I’ve just updated my code and the plugin, and it works fine.

    Plugin Support Michael Nelson

    (@mnelson4)

    Ok great, I’m going to close this issue then. It was a good question.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘related_posts()’ is closed to new replies.