Multisite - Get current post id
I'm using WPMU in my project, but I'm facing some problems to get the current post id from all sites. If I run this code, I receive the same post id of current site and not the different post id from all other sites. It's like that switch_to_blog
doesn't work. How can I get all ids of current post from all sites?
$sites = get_sites();
/** @var WP_Site $site */
foreach ($sites as $site) {
if ( $site-archived || $site-spam || $site-deleted ) {
continue;
}
switch_to_blog( $site-blog_id );
var_dump( get_the_ID() );
}
restore_current_blog();
die;
Topic switch-to-blog multisite posts Wordpress
Category Web