我使用此代码在主站点中的帖子上循环:
<?php
$sites = wp_get_sites();
foreach($sites as $site) :
// Only subsites
// Connect to new multisite
switch_to_blog($site[\'blog_id\']);
$case_args = array(
\'post_type\' => \'downloads\',
\'posts_per_page\' => 1,
\'orderby\' => \'date\',
\'order\' => \'DESC\',
);
$latest_cases = new WP_Query($case_args);
if ( $latest_cases->have_posts() ) : ?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query();
// Quit multisite connection
restore_current_blog();
endforeach;
?>