If we add a blog post in main site that post need to be display in minisite (subsite)

  • Do you want the post to be copied - like it should show up in the dashboard for the subsite? Or you just want it to be displayed in the subsite?
    – mozboz
    Jul 16 '20 at 11:15
  • The blog post should be just display in subsite.If we add blog post that post need to be just display in subsite
    – user191721
    Jul 16 '20 at 11:51
  • 1
    What have you tried so far?
    – WebElaine
    Jul 16 '20 at 14:16

I can't write the whole solution for what you need, but to achieve this you need to add code to your theme using functions like these which help you to figure out which multisite you're on, and pull a post from a different multisite:

get_current_blog_id() - get current multisite site ID

switch_to_blog(123) - switch to multisite ID 123

restore_current_blog() - if you switched to a different site, switch back to the one you were on before

So if your 'main site' is blog ID '1' then you probably need to add some code to your theme that does something like this:

    $mainSite = 1;
    $currentSite = get_current_blog_id();

    if ($currentSite != $mainSite) {
        // get_posts, WP_Query, etc. to get the posts you want

        // post loop to print the post


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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