Title: [Plugin: Yet Another Related Posts Plugin] Custom post types
Last modified: August 19, 2016

---

# [Plugin: Yet Another Related Posts Plugin] Custom post types

 *  [jompa](https://wordpress.org/support/users/jompa/)
 * (@jompa)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/)
 * YARPP doesn’t seem to work with custom post types. Haven’t found any information
   about this on the forum nor the manual. Is there any way to make these work together?
 * Regards
    /J

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/page/2/?output_format=md)

 *  [adambundy](https://wordpress.org/support/users/adambundy/)
 * (@adambundy)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/#post-1536274)
 * Im looking to do this as well. Anyone have a tip? Thanks!
 *  [rossit](https://wordpress.org/support/users/rossit/)
 * (@rossit)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/#post-1536294)
 * I’ve got YARPP showing in my custom post type… but I don’t want it there! Can
   YARPP offer the ability to turn off for custom post types entirely please?
 *  [timothyharter](https://wordpress.org/support/users/timothyharter/)
 * (@timothyharter)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/#post-1536310)
 * I would love a combination of the above. To have separate related posts for each
   of my posts and custom post types. (eg. related blog posts on my blog pages, 
   and related “movies” on my “movies” custom post type pages, and even related “
   podcasts” on my “podcasts” custom post type pages. And all at the same time)
 * I am sure there are even some people (maybe even me in the future) who would 
   like to see the ability to add any related content to any post. So maybe I have
   a blog post about zombies. I could show 3 zombie related blog posts, plus 3 zombie
   movies, and 3 podcasts on zombies, all under on the page for my blog post about
   Zombies. Now that would be something else. 😉
 *  [mitcho (Michael Yoshitaka Erlewine)](https://wordpress.org/support/users/mitchoyoshitaka/)
 * (@mitchoyoshitaka)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/#post-1536315)
 * [@rossit](https://wordpress.org/support/users/rossit/): try turning of the “automatically
   display” option in YARPP settings and instead add the code `related_posts()` 
   to the template files where you *do* want to show them.
 * [@jompa](https://wordpress.org/support/users/jompa/), [@adambundy](https://wordpress.org/support/users/adambundy/):
   this is on my todo list:
 * [http://plugins.trac.wordpress.org/ticket/1142](http://plugins.trac.wordpress.org/ticket/1142)
 *  [unodewaal](https://wordpress.org/support/users/unodewaal/)
 * (@unodewaal)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/#post-1536318)
 * Just a bump up here – I really would like this functionality as well.
 *  [nkuttler](https://wordpress.org/support/users/nkuttler/)
 * (@nkuttler)
 * [15 years, 7 months ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/#post-1536376)
 * [@unodewaal](https://wordpress.org/support/users/unodewaal/) You could have a
   look at [http://wordpress.org/extend/plugins/better-related/](http://wordpress.org/extend/plugins/better-related/)
   which supports listing related custom post types.
 *  [hash95](https://wordpress.org/support/users/hash95/)
 * (@hash95)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/#post-1536382)
 * This how I modify it to accept Custom Post Type (for example : video):
 * **single.php :**
    `related_posts('video');`
 * **related-functions.php :**
    > line 7
 *     ```
       function related_posts($posttype = 'post', $a = array(),$echo=true,$reference_ID=false) {
       	return yarpp_related(array($posttype),$a,$echo,$reference_ID);
       }
       ```
   
 * **magic.php :**
    > line 283 (maybe the number of the lines are wrong)
 * > // get the related posts from postdata, and also construct the relate_IDs array
   > 
   > $yarpp_related_postdata = get_post_meta($reference_ID,YARPP_POSTMETA_RELATED_KEY,
   > true);
 * – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
 * Here we have to modify how it get the related ID (of posts).
    This is how it 
   works : **1) yarpp.php**
 * > // update cache on save
   >  add_action(‘save_post’,’yarpp_save_cache’);
 * ->
 * **2) magic.php**
 * > function yarpp_save_cache($post_ID,$force=true)
 *     ```
       if (yarpp_get_option('cross_relate'))
       		$type = array('post','page');
       	elseif ($post_type == 'page')
       		$type = array('page');
               elseif ($post_type == 'video')
                       $type = array('video');
       	else
       		$type = array('post');
       ```
   
 * **3) magic.php**
 * > function yarpp_cache_enforce($type=array(‘post’),$reference_ID,$force=false)
   > -
   > > $related = $wpdb->get_results(yarpp_sql($type,array(),true,$reference_ID),
   > ARRAY_A);
 * **4) magic.php**
 * > function yarpp_sql($type,$args,$giveresults = true,$reference_ID=false,$domain
   > =’website’)
 *     ```
       if ($type == array('page') && !$cross_relate)
           $newsql .= " and post_type = 'page'";
         elseif ($type == array('video'))
           $newsql .= " and post_type = 'video'";
         else
           $newsql .= " and post_type = 'post'";
       ```
   
 * You can improve the script trying to accept multiple Custom Post Type :
    related_posts(
   array(‘video’,’portfolio’,’gallery’)); …
 *  [mitcho (Michael Yoshitaka Erlewine)](https://wordpress.org/support/users/mitchoyoshitaka/)
 * (@mitchoyoshitaka)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/#post-1536383)
 * [@hash95](https://wordpress.org/support/users/hash95/) thanks for the tips!
 * Note that this code is hard coded to the custom post type name you are using.
   I may implement a more general solution in the future.
 * If you would like to support the development of this (or other) features, here’s
   YARPP’s fundry page:
 * [https://fundry.com/project/13-yet-another-related-posts-plugin-for-wordpress](https://fundry.com/project/13-yet-another-related-posts-plugin-for-wordpress)
 *  [noizeburger](https://wordpress.org/support/users/noizeburger/)
 * (@noizeburger)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/#post-1536406)
 * Hi,
 * any news on custom-post-types-support? I’m using the arras-theme which has already
   yarpp-support. But I’m using several custom-post-types, so I’m in need of this
   functionality. I’m not sure about how to integrate the above lines of code – 
   also don’t know if it works at all.
 * Thanks in advance,
    Harald
 *  [mitcho (Michael Yoshitaka Erlewine)](https://wordpress.org/support/users/mitchoyoshitaka/)
 * (@mitchoyoshitaka)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/#post-1536407)
 * Sorry, no news yet.
 *  [doctorcilantro](https://wordpress.org/support/users/doctorcilantro/)
 * (@doctorcilantro)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/#post-1536410)
 * I’ve tried to integrate the code above to no avail for my custom post type.
 * My funds are standing by if someone has a solution.
 *  [mitcho (Michael Yoshitaka Erlewine)](https://wordpress.org/support/users/mitchoyoshitaka/)
 * (@mitchoyoshitaka)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/#post-1536411)
 * Your “funds”?
 *  [doctorcilantro](https://wordpress.org/support/users/doctorcilantro/)
 * (@doctorcilantro)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/#post-1536412)
 * funds = donation to dev.
 * or I can just hit freelancer
 *  [mitcho (Michael Yoshitaka Erlewine)](https://wordpress.org/support/users/mitchoyoshitaka/)
 * (@mitchoyoshitaka)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/#post-1536413)
 * If you are looking for this feature in the next few months, at least, I would
   recommend you find a contractor. I don’t have any plans to add this soon, and
   don’t do “sponsored” features. Feel free to donate if you appreciate YARPP as
   it is, though. 🙂
 *  [jcskyrocket](https://wordpress.org/support/users/jcskyrocket/)
 * (@jcskyrocket)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/#post-1536428)
 * Hey Mitcho, any news on: [http://plugins.trac.wordpress.org/ticket/1142](http://plugins.trac.wordpress.org/ticket/1142)?

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/page/2/?output_format=md)

The topic ‘[Plugin: Yet Another Related Posts Plugin] Custom post types’ is closed
to new replies.

 * 17 replies
 * 12 participants
 * Last reply from: [johnnymestizo](https://wordpress.org/support/users/johnnymestizo/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/plugin-yet-another-related-posts-plugin-custom-post-types/page/2/#post-1536430)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
