Viewing 1 replies (of 1 total)
  • Plugin Author keesiemeijer

    (@keesiemeijer)

    Hi techlector

    There is no offset argument at the moment. If you know the post IDs you want to skip you can use the exlude_posts argument.

    https://keesiemeijer.wordpress.com/related-posts-by-taxonomy/#exclude-posts

    Or use this in your (child) theme’s functions.php file.

    
    add_filter( 'related_posts_by_taxonomy', 'rpbt_add_offset', 10, 4 );
    
    function rpbt_add_offset( $results, $post_id, $taxonomies, $args ) {
    
    	// Offset of 2 related posts
    	$offset = 2;
    
    	// Remove related posts
    	array_splice( $results, 0, $offset );
    
    	return $results;
    }
    

    You’ll need to add the offset (2) to the amount of posts you want to show.

    btw:
    consider creating a child theme instead of editing your theme directly – if you upgrade the theme all your modifications will be lost. Or create a plugin with the code above.

Viewing 1 replies (of 1 total)
  • The topic ‘How to Offset posts’ is closed to new replies.