• 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)
  • Im looking to do this as well. Anyone have a tip? Thanks!

    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?

    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. ??

    @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, @adambundy: this is on my todo list:

    https://plugins.trac.www.ads-software.com/ticket/1142

    Just a bump up here – I really would like this functionality as well.

    nkuttler

    (@nkuttler)

    @unodewaal You could have a look at https://www.ads-software.com/extend/plugins/better-related/ which supports listing related custom post types.

    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’));

    @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

    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

    Sorry, no news yet.

    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.

    Your “funds”?

    funds = donation to dev.

    or I can just hit freelancer

    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. ??

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘[Plugin: Yet Another Related Posts Plugin] Custom post types’ is closed to new replies.