0

Is it possible to get the post excerpt from a different site in my Multisite Network?

1 Answer 1

2

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}";
2
  • 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
  • I can't accept answers as a "guest". Sorry...
    – Frank
    Commented Dec 19, 2017 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.