Automatically Crosspost Posts From a Specific Category Only
Both of my crossposting plugins have the “Auto Mode” feature that allows you to publish posts automatically to all connected sites without selecting them for each post manually.
But what if you’d like to autopublish only specific posts? Let’s say from a specific category or tag? In that case, I prepared this article for you for both my Simple WP Crossposting plugin (standalone websites) and Simple Multisite Crossposting (WordPress Multisite network).
Standalone Sites
This part of the article is dedicated to my Simple WP Crossposting plugin. If you’re looking for a solution for the multisite version of the plugin, scroll down below.
First of all, please make sure that the “Auto Mode” option is enabled in the plugin settings:

Second, use a code snippet to configure auto-crossposting:
add_filter( 'rudr_swc_auto_mode_sites', function( $sites, $post_id ) {
// if post is in category "Travel", only then we're crossposting it
if( in_category( 'travel', $post_id ) ) {
return $sites;
}
// you can use use has_tag() function to check post tags
return array();
}, 20, 2 );If you don’t know where to insert this piece of code, please check this guide or watch the video below:
There is also a possibility for more detailed configuration, for example, if a post is in a specific category, you can auto-crosspost it to a specific site only.
add_filter( 'rudr_swc_auto_mode_sites', function( $sites, $post_id ) {
$allowed_sites = array();
if( in_category( 'travel', $post_id ) ) {
foreach( $sites as $site ) {
if( 'https://rudrastyh.com' === $site[ 'url' ] ) {
$allowed_sites[] = $site;
}
}
}
return $allowed_sites;
}, 20, 2 );Now let’s take a look at a more complex example. What if you would like to crosspost to “Site 1” if “Category 1” is selected, to “Site 2” when “Category 2” is selected, and to “Site 3” when “Category 3” is selected? Then, here is the snippet for you:
add_filter( 'rudr_swc_auto_mode_sites', function( $sites, $post_id ) {
$allowed_sites = array();
// replace 'category-1' with your category slug
if( in_category( 'category-1', $post_id ) ) {
foreach( $sites as $site ) {
// replace "Site 1 URL" with the website url with https://
if( 'Site 1 URL' === $site[ 'url' ] ) {
$allowed_sites[] = $site;
}
}
}
// replace 'category-2' with your category slug
if( in_category( 'category-2', $post_id ) ) {
foreach( $sites as $site ) {
// replace "Site 2 URL" with the website url with https://
if( 'Site 2 URL' === $site[ 'url' ] ) {
$allowed_sites[] = $site;
}
}
}
// replace 'category-3' with your category slug
if( in_category( 'category-3', $post_id ) ) {
foreach( $sites as $site ) {
// replace "Site 2 URL" with the website url with https://
if( 'Site 3 URL' === $site[ 'url' ] ) {
$allowed_sites[] = $site;
}
}
}
return $allowed_sites;
}, 20, 2 );As a first parameter of the in_category() function, you can use a category name, slug, or ID.
Sites within a WordPress Multisite network
Now, let’s talk about a multisite version of the plugin, Simple Multisite Crossposting. Let’s start with the moment that the “Auto mode” feature in it is site-specific. It means you can activate or deactivate it for each sub-site in your multisite network individually.
Let’s do it in a site’s settings, in Sites > Edit > Crosspost.

After that, you can use the rudr_smc_auto_mode_blog_ids filter hook on this specific sub-site. If you want to network-activate it, then you’d probably need to add one more condition with the get_current_blog_id() function.
Let’s try to re-create the same examples from the first part of this support article.
add_filter( 'rudr_smc_auto_mode_blog_ids', function( $blog_ids, $post_id ) {
// if post is in category "Travel", only then we're crossposting it
if( in_category( 'travel', $post_id ) ) {
return $blog_ids;
}
return array();
}, 20, 2 );Now, it is time for a more complicated task – to crosspost to “Blog 1” if “Category 1” is selected, to “Blog 2” when “Category 2” is selected, and to “Blog 3” when “Category 3” is selected (yes, we already did that before for a non-multisite version of the plugin).
add_filter( 'rudr_smc_auto_mode_blog_ids', function( $blog_ids, $post_id ) {
$allowed_blog_ids = array();
// replace 'category-1' with your category slug
if( in_category( 'category-1', $post_id ) ) {
$allowed_blog_ids = array_filter( $blog_ids, function( $blog_id ) {
return in_array( $blog_id, array( 1 ) );
} );
}
// replace 'category-2' with your category slug
if( in_category( 'category-2', $post_id ) ) {
$allowed_blog_ids = array_filter( $blog_ids, function( $blog_id ) {
return in_array( $blog_id, array( 2 ) );
} );
}
// replace 'category-3' with your category slug
if( in_category( 'category-3', $post_id ) ) {
$allowed_blog_ids = array_filter( $blog_ids, function( $blog_id ) {
return in_array( $blog_id, array( 3 ) );
} );
}
return $allowed_blog_ids;
}, 20, 2 );I tried to make this example as similar as possible to the example from the beginning of this article. The in_array() function, by the way, allows you to specify multiple blog IDs to compare with.