Exclude Only 1 blog post from a particular function

Dear Support,

Im using this function in my functions.php to add Sharing buttons at the bottom of my content of my blog posts:

function display_sharing_buttons( $content ) { 

if ( is_singular('post') ) {

$content.=do_shortcode("[mashshare]");
}
return $content;
}
add_filter( 'the_content', 'display_sharing_buttons', 19 );

I need to exclude 1 or two blog posts from this function so i wont show the sharing buttons there.
Is there a way to do that ?

Thanks in advance.

Hi There,

Please update your code to this:

function display_sharing_buttons( $content ) { 

	if ( is_singular('post') && !is_single( array(123, 456) ) ) {

		$content.=do_shortcode("[mashshare]");
	}
	return $content;
}
add_filter( 'the_content', 'display_sharing_buttons', 19 );

The 123 and 456 number is your post IDs.

Let us know how it goes!

Works perfectly! Thanks a lot @thai

You’re welcome :slight_smile:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.