• Resolved mhazenet

    (@mhazenet)


    I am using this plugin to show related posts. One related post is added inline within content via a block. Then two more at the bottom of a post. I want to prevent the same post from showing in two places. Offset doesn’t seem to be supported, but that would be ideal. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author keesiemeijer

    (@keesiemeijer)

    Hi mhazenet

    As you said offset is not supported right now.

    Do you use the shortcode to display the related posts?

    • This reply was modified 5 years, 5 months ago by keesiemeijer.
    Thread Starter mhazenet

    (@mhazenet)

    No, I’m using function within the theme code. Here’s a sample:

    
    /**
     * This function is used to retrieve call-to-action items only.
     */
    function setup_related_call_to_action($post_id, $taxonomies, $post_type){
    	if ( function_exists( 'km_rpbt_get_related_posts' ) ) {
    
    		$post_types = array('call-to-action');
    
    		$args = array(
    			'taxonomies'     => $taxonomies,
    			'include_self'   => false,
    			'post_types' 	   => $post_types,
    			'order'			     => 'DESC',
    			'orderby'        => 'post_date'
    		);
    	
    		global $related_call_to_action_posts;
    		global $related_call_to_action_posts_counter;
    
    		$related_call_to_action_posts = get_field('related_ctas_sidebar', $post_id);
    
    		// If no manual relationship found, relate by taxonomy via plugin
    		if( !is_array( $related_call_to_action_posts ) || count( $related_call_to_action_posts ) == 0 ){
    			$related_call_to_action_posts = km_rpbt_get_related_posts( $post_id, $args );			
    		}
    
    		$related_call_to_action_posts = array_reverse($related_call_to_action_posts);
    		$related_call_to_action_posts_counter = 0;
    	}
    
    	return;	
    }
    
    • This reply was modified 5 years, 5 months ago by keesiemeijer.
    Plugin Author keesiemeijer

    (@keesiemeijer)

    Is the post id in this line the one you want to exclude?

    
    $related_call_to_action_posts = get_field('related_ctas_sidebar', $post_id);
    

    If so you can use the exclude_posts argument
    https://keesiemeijer.wordpress.com/related-posts-by-taxonomy/#exclude-posts

    Thread Starter mhazenet

    (@mhazenet)

    That makes sense. Thanks for your help, and thanks for providing this plugin.

    Plugin Author keesiemeijer

    (@keesiemeijer)

    You’re welcome ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Is it possible to add offset to skip a number of new posts?’ is closed to new replies.