There isn’t but you can use switch_to_blog()
function to switch to a certain site then use regular WordPress function to check if any post on the post type is exists or not.
For Example
add_action('wp_loaded', 'wpse167721_check_networkwide_events');
function wpse167721_check_networkwide_events(){
global $wpdb;
$original_blog_id = get_current_blog_id(); // get the original blog id
// get network sites
$args = array(
'network_id' => $wpdb->siteid,
'public' => null,
'archived' => null,
'mature' => null,
'spam' => null,
'deleted' => null,
'limit' => 100,
'offset' => 0,
);
$sites = wp_get_sites($args);
foreach($sites as $site){
// switch to blog
switch_to_blog($site['blog_id']);
if(!wpse167721_is_event_exists())
continue; // skip current iteration and go to the next one
// Event exists! do whatever you want to do
}
// lets switch to our original blog
switch_to_blog($original_blog_id);
}
function wpse167721_is_event_exists(){
$args = array(
'post_type' => 'event', // change the cpt name here
'posts_per_page' => 1,
'fields' => 'ids'
);
return count(get_posts($args));
}
Caution:
This code will run for every blog in the network on every page load (because it is hooked into wp_loaded
). If you have a large network then consider batch processing.
code not tested