Is it possible to get the post excerpt from a different site in my Multisite Network?
1 Answer
Yes, using switch_to_blog()
you can load another Wordpress site, get what you want, then revert back to your current site and carry forward any retrieved data.
// the different site ID in your Wordpress Network
$otherSite = 3;
// the post excerpt you're after in the different site
$otherSitesPost = 42;
switch_to_blog( $othersite );
$otherSitesPostExcerpt = get_post($otherSitesPost)->post_excerpt;
restore_current_blog();
echo "Site #{$otherSite} post #{$otherSitesPost} excerpt: {$otherSitesPostExcerpt}";
-
great, glad to help. if that answered the question for you be sure to mark it as answered! if you've got any more questions feel free to ask Commented Dec 19, 2017 at 19:12
-