Skip to content

Snippet: Exclude Current Post From Post Series

By default the theme's Post Series function displays a list of all posts that below to the current post's "series" and includes the current Post so you can see it's position within the series. This snippet will remove the current post from the list.

/**
 * Removes the current post from the post series display.
 *
 * @link https://total.wpexplorer.com/docs/snippets/post-series-exclude-current-post/
 */
add_filter( 'wpex_post_series_query_args', function( $args ) {
	$args['post__not_in'] = array( get_the_ID() );
	return $args;
} );
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top