WordPress.org

Ready to get started?Download WordPress

Forums

Yet Another Related Posts Plugin (YARPP)
[resolved] Where do I get started with Related Posts for a CPT (8 posts)

  1. stoi2m1
    Member
    Posted 9 months ago #

    Can I get a little help here? Im not the only one looking for assistance in this area, there are a couple of others looking for assistance in another thread within this support forum.

    Thanks,
    Jesse

    http://wordpress.org/plugins/yet-another-related-posts-plugin/

  2. jeffparker
    Member
    Plugin Author

    Posted 9 months ago #

    Please see the "Other Notes" subhead in this section: http://wordpress.org/plugins/yet-another-related-posts-plugin/other_notes/

    Once you take a look there, I may be able to help if you're still having trouble.

    Thanks.

  3. stoi2m1
    Member
    Posted 9 months ago #

    Jeff,

    Have you seen that page? It talks about some function which you can use but has no working examples and gives little clue as to were to get started.

    Here is what I have and I keep getting "No related posts."

    I have a custom post type of movies. With a Custom Taxonomies of movie-genre which I would like to get related results based on.

    Here is the code I am trying to use:

    yarpp_related(
    	array(
    		'post_type' => array('movies'),
    		'show_pass_post' => false,
    		'past_only' => false,
    		'recent' => false,
    		'weight' => array(
    			'body' => 1,
    			'title' => 2,
    			'tax' => array(
    				'movie-genre' => 1
    			)
    		),
    		'require_tax' => array(
    			'movie-genre' => 1
    		),
    		'threshold' => 5,
    		'template' => false,
    		'limit' => 5,
    		'order' => 'score DESC'
    	),
    	$post->ID,
    	true
    );

    If you could explain how I am using this wrong or why its returning "No related posts". I would appreciate it very much.

    Thanks,
    Jesse

  4. chaleybgis
    Member
    Posted 9 months ago #

    I think that you need to add the yarrp_support parameter when you register your CPT.

    Like this:

    add_action( 'init', 'create_post_type' );
    function create_post_type() {
    	register_post_type( 'acme_product',
    		array(
    			'labels' => array(
    				'name' => __( 'Products' ),
    				'singular_name' => __( 'Product' )
    			),
    		'public' => true,
    		'has_archive' => true,
                    'yarpp_support' => true
    		)
    	);
    }

    If you've created the CPT with a plugin, you may have to remove it and add it via functions.php. If you're using Custom Post Type UI I think you can export your post type to a function then add the yarpp_support parameter.

    Note: I haven't tested this and have no idea if it will work or not.

  5. stoi2m1
    Member
    Posted 9 months ago #

    Where did you get that info from? Is there supporting documentation?

    I had already defined my CPT in my functions.php file so I just added the following line into my CPT array:

    'yarpp_support' => true

    The results were "No related posts."

    PS. If you have no idea how are you sharing an idea? Dont discredit yourself. It makes your information seem unworthy and almost had me not even bother trying it.

  6. stoi2m1
    Member
    Posted 9 months ago #

    @chaleybgis - Thank You!

    After I updated the part you mentioned. I sought out where in the plugin was something like this required. I found that the class-core.php has a filter function called post_type_filter(). Which validated the current post type for having yarpp_support. Thank you for that tid bit of MOST USEFUL information.

    Once I found this piece of code was required and I noticed the widget started working. I then realized I had some errors in my yarpp_related() function call.

    IT WOULD BE NICE IF THIS WAS DOCUMENTED SOMEWHERE!
    <strong>be sure to add</strong>
    'yarpp_support' => true //place this in your register post type function

    Thanks Again,
    Jesse

  7. chaleybgis
    Member
    Posted 9 months ago #

    Actually that documentation was the first line on the link that jeffparker provided

    Custom post types

    To make YARPP support your custom post type, the attribute yarpp_support must be set to true on the custom post type when it is registered. It will then be available on options on the YARPP settings page.

  8. jeffparker
    Member
    Plugin Author

    Posted 9 months ago #

    Thanks, chaleybgis, for your help explaining!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.