Support » Networking WordPress » [Plugin: Improved Include Page] How to Include Page to an other Multiblog-Site

  • Resolved bhenselmann


    I’ld like to include a page from one WP-Site in to an other WP-Site. Both sites are in the same WP-Multisite installation.
    Has anybody an idea how to resolve this?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator Ipstenu (Mika Epstein)


    Lead Plugin Wrangler

    At a guess … You know where you make these calls:
    <?php echo iinclude_page(4, null, true); ?>

    Before that echo, you would want to use switch_to_blog().

    CAVEAT Doing this a bunch of times will slow your site down, so be cautious.

    Andrea Rennick


    Customer Care at Copyblogger Media and Studiopress

    And also clicking those links will literally take the viewer to the other blog.

    Thanks Ipstenu for the hint with switch_to_blog(). I didn´t revognized this funktion up to now.
    I´ve found an other way in the meantime, which do it all together: get_blog_post($blogID,$pageID).

    Zambrano Sergio


    YES!! bhenselmann!! You answered all my questions!!

    Do you think of many problems (if less than 3, I’ll do it!) by replacing the “get_page()” functions with “get_blog_post()” instead?

    -and adding my main site’s ID as the first parameter –

    That’d make my day perfect until wp provides “mirror” or “alias” pages to get some pages to be shared across the network.


    Zambrano Sergio


    Ohh… I jumped the gun 🙁

    I know the title of the page I want to access, but the ID could be different for each site, and in order to get_page_by_title() I need to switch the blog first. Exactly what I though I could avoid.

    Anyway, you answered something nobody answered, a function right inside WordPress!! 🙂

    Anyway, I’d be cool this plugin get that parameter included for new-coming multisites.

    Hi, I’m researching something along the same lines – show some specific blog posts from each blog in a view on the main blog. Thanks @bhenselmann for that code, looks like it will do the trick without a bunch of coding. Nice one!

    @sergiozambrano – You don’t necessarily have to switch_to_blog(). You could use $wpdb->set_blog_id() instead; and pull the post info directly out of the database.

    The code might look something like:

    function get_page_by_title_from_blog( $post_title, $blog_id=0 ) {
      if( 0 == $blog_id || !is_numeric( $blog_id ) )
        return get_page_by_title( $post_title );
      global $wpdb;
      $org_blog = $wpdb->set_blog_id( $blog_id );
      $page = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->posts} WHERE post_title=%s AND post_type=%s", $post_title, 'page' ) );
      $wpdb->set_blog_id( $org_blog );
      return $page;

    @curtiss Grymala – Yes, your code is exactly what I try to avoid. I don’n like to ping the database myself, where I have functions for that. If I learned the database structure and where each piece of info is used (and how the DB will change in the future updates to avoid soon-to-be-deprecated data) I wouldn’t have any more kb spare in my head to remember wp functions I need for layouts! hehe.

    When I feel more comfortable with database messing (which I see easy enough already) I’ll give it a shot 🙂

    So far I fixed it with threewp broadcast plugin. Badly tagged but solved all my needs.

    but this piece of code from Bhenselmann was the solution to this post
    Thanks a lot for your help.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: Improved Include Page] How to Include Page to an other Multiblog-Site’ is closed to new replies.