apply_filters ( 'publicize_should_publicize_published_post', bool $should_publicize, WP_POST $post )

Determines whether a post being published gets publicized.<p>Side-note: Possibly our most alliterative filter name.</p>

Source file: modules/publicize/publicize-jetpack.php

View in GitHub

Parameters

$should_publicize

(bool) Should the post be publicized? Default to true.

$post

(WP_POST) Current Post object.


Changelog

Since: Jetpack 4.1.0


Notes

In the example below, we won’t publicize any post using the private tag:

/**
 * Do not trigger Publicize if the post uses the `private` tag.
 */
function jeherve_control_publicize( $should_publicize, $post ) {
	// Return early if we don't have a post yet (it hasn't been saved as a draft)
	if ( ! $post ) {
		return $should_publicize;
	}

	// Get list of tags for our post.
	$tags = wp_get_post_tags( $post->ID );

	// Loop though all tags, and return false if the tag's name is `private`
	foreach ( $tags as $tag ) {
		if ( 'private' == $tag->name ) {
			return false;
		}
	}

	return $should_publicize;
}
add_filter( 'publicize_should_publicize_published_post', 'jeherve_control_publicize', 10, 2 );

Have a note to contribute?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Comments

  1. djfloopstt says:

    how to do it for categories just change tag to cat?