Is this correct to exclude certain categories from Publicize?
-
Is this the correct way to exclude these three categories from being auto shared with Publicize?
My category ID’s are 751,752,753
and their slugs are:
guest-blogger1
guest-blogger2
guest-blogger3add to functions.php
/**
* Do not trigger Publicize if the post uses the guest blogger categories.
*/
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.
wp_get_post_categories( $post->751,array(‘fields’ => ‘all’ )) ;
wp_get_post_categories( $post->752,array(‘fields’ => ‘all’ )) ;
wp_get_post_categories( $post->753,array(‘fields’ => ‘all’ )) ;// Loop though all categories, and return false if guest blogger categories.
foreach ( $categories as $categories ) {
if ( ‘guest-blogger1’ == $categories->name ) {
if ( ‘guest-blogger2’ == $categories->name ) {
if ( ‘guest-blogger3’ == $categories->name ) {
return false;
}
}return $should_publicize;
}
add_filter( ‘publicize_should_publicize_published_post’, ‘jeherve_control_publicize’, 10, 2 );
- The topic ‘Is this correct to exclude certain categories from Publicize?’ is closed to new replies.