• Resolved Pancho Perez

    (@lonchbox)


    I´m using the PHP function to call YARPP posts outside of the post loop, also I use single.php for two different post_types. This is ok?

    <?php if (is_singular('rezepte')): ?>
    			<?php if(function_exists('related_posts')){
    					related_posts(array(
    				  'post_type' => array('rezepte'),
    				  'show_pass_post' => true,
    				  'past_only' => false,
    				  'threshold' => 0,
    				  'template' => 'yarpp-template-rezepte.php',
    				  'limit' => 3,
    				  'order' => 'score DESC'
    				), $post->ID , true);
    			} ?>
    		<?php else: ?>
    			<?php if(function_exists('related_posts')){
    					related_posts(array(
    				  'post_type' => array('post'),
    				  'show_pass_post' => true,
    				  'past_only' => false,
    				  'threshold' => 0,
    				  'template' => 'yarpp-template-posts.php',
    				  'limit' => 3,
    				  'order' => 'score DESC'
    				), $post->ID , true);
    			} ?>
    		<?php endif; ?>

    The problem is everytime I get the same posts, no matter if I flush cache (yarpp experiments).

    Any idea? Thanx.

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Pancho Perez

    (@lonchbox)

    Fixed.

    Just add this before the related_posts array

    wp_reset_query();
    related_posts(array(

    And for the relation, increase the threshold to 1.

    Plugin Author YARPP

    (@jeffparker)

    Great! Glad that’s working for you now.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PHP function outside the loop and conditional statement for different post type’ is closed to new replies.