Title: related_posts()
Last modified: February 25, 2021

---

# related_posts()

 *  Resolved [gatta2](https://wordpress.org/support/users/gatta2/)
 * (@gatta2)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/related_posts/)
 * 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](https://wordpress.org/support/users/cnxsoft/)
 * (@cnxsoft)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/related_posts/#post-14101193)
 * 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](https://wordpress.org/support/users/mnelson4/)
 * (@mnelson4)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/related_posts/#post-14118902)
 * Hi [@gatta2](https://wordpress.org/support/users/gatta2/) and [@cnxsoft](https://wordpress.org/support/users/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](https://wordpress.org/support/users/cnxsoft/)
 * (@cnxsoft)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/related_posts/#post-14120229)
 * Thank you Michael. I’ve just updated my code and the plugin, and it works fine.
 *  Plugin Support [Michael Nelson](https://wordpress.org/support/users/mnelson4/)
 * (@mnelson4)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/related_posts/#post-14158870)
 * 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.

 * ![](https://ps.w.org/yet-another-related-posts-plugin/assets/icon-256x256.png?
   rev=2549977)
 * [YARPP - Yet Another Related Posts Plugin](https://wordpress.org/plugins/yet-another-related-posts-plugin/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yet-another-related-posts-plugin/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yet-another-related-posts-plugin/)
 * [Active Topics](https://wordpress.org/support/plugin/yet-another-related-posts-plugin/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yet-another-related-posts-plugin/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yet-another-related-posts-plugin/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [Michael Nelson](https://wordpress.org/support/users/mnelson4/)
 * Last activity: [5 years, 3 months ago](https://wordpress.org/support/topic/related_posts/#post-14158870)
 * Status: resolved