WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Yet Another Related Posts Plugin] Custom post types (18 posts)

  1. jompa
    Member
    Posted 4 years ago #

    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

  2. adambundy
    Member
    Posted 4 years ago #

    Im looking to do this as well. Anyone have a tip? Thanks!

  3. RossiT
    Member
    Posted 4 years ago #

    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?

  4. timothyharter
    Member
    Posted 4 years ago #

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

  5. @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:

    http://plugins.trac.wordpress.org/ticket/1142

  6. unodewaal
    Member
    Posted 4 years ago #

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

  7. nkuttler
    Member
    Posted 3 years ago #

    @unodewaal You could have a look at http://wordpress.org/extend/plugins/better-related/ which supports listing related custom post types.

  8. hash95
    Member
    Posted 3 years ago #

    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'));
    ...

  9. @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

  10. noizeburger
    Member
    Posted 3 years ago #

    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

  11. Sorry, no news yet.

  12. doctorcilantro
    Member
    Posted 3 years ago #

    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.

  13. Your "funds"?

  14. doctorcilantro
    Member
    Posted 3 years ago #

    funds = donation to dev.

    or I can just hit freelancer

  15. 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. :)

  16. jcskyrocket
    Member
    Posted 3 years ago #

  17. @jcskyrocket nope. You can cc yourself on that bug so you learn about any progress, though.

  18. johnnymestizo
    Member
    Posted 3 years ago #

    try this

    http://wordpress.org/extend/plugins/better-related/

    with full custom post type support

Topic Closed

This topic has been closed to new replies.

About this Topic