• Resolved littlebizonline

    (@littlebizonline)


    Is there a way to exclude the current post from the list of posts?
    E.g. I am in Post A, and when I see the list of posts from the same category as “related posts”, I don’t really want Post A to be in the list (because I am already reading it).

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Tajam

    (@tajam)

    No feature like this yet, but you can use the code below. Copy this code to functions.php in your theme/child theme:

    function yourtheme_flex_posts_list_args( $args ) {
    	$post_id = get_the_ID();
    	if ( ! empty( $post_id ) ) {
    		$args['post__not_in'] = array( $post_id );
    	}
    	return $args;
    }
    add_filter( 'flex_posts_list_args', 'yourtheme_flex_posts_list_args' );
    
    Thread Starter littlebizonline

    (@littlebizonline)

    Awesome – thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude self’ is closed to new replies.