6

Is it possible to manage content on multisite installations centrally? If I have a network of 20 sites, is it possible to change the content on one site and have it update across the network, or will I have to make the change on each site one at a time? More specific case, If I have a Terms and Conditions page that must appear on each site, that requires periodic changes can I make the change once and have it replicate.

Any suggestions/directions/resources for managing this process effectively would be appreciated.

1
  • Thanks for all of the responses. I expect at some point I'll try all of the solutions. A special thanks to Bainternet for sharing his plugin. Even I could follow it. Ultimately, I accepted the plugin solution offered by Davemac as it offered a lot of flexibility. Commented Jun 9, 2012 at 18:10

3 Answers 3

5
+50

I've successfully used the ThreeWP Broadcast plugin to do this on a WPMU installation.

The basic concept is that you have one 'broadcasting' site from which you can broadcast content to other sites. The content can be posts, pages, custom post types, custom taxonomies, post meta or attachments.

If content is updated on the 'broadcasting' site, the updates will be reflected on the other sites. More info can be found on the ThreeWP Broadcast WP Plugin Directory entry linked above.

1
  • +1+ For pointing out this one, bookmarked. It seems as Bainternet's code on steroids :)
    – brasofilo
    Commented Jun 6, 2012 at 20:38
7

I had a similar problem where i needed content to be available "network-wide" and managed from one location (main site), So i created a custom post type in the main site called "shared content" and a nice little shortcode which pulls the content from the main site.

And here is "a version" of it but its not test since i don't have access to the working solution i used back then, but it should work just fine:

<?php
/*
Plugin Name: WPMU Shared Content
Plugin URI: http://en.bainternet.info
Description: This plugin lets you create and manage content on the main MU installation and shared it accros you network
Version: 0.1
Author: Bainternet
License:

  Copyright 2012 Bainternet ([email protected])

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License, version 2, as 
  published by the Free Software Foundation.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/
/* Disallow direct access to the plugin file */
if (basename($_SERVER['PHP_SELF']) == basename (__FILE__)) {
        die('Sorry, but you cannot access this page directly.');
}

if (!class_exists('wpmu_shared_content')){

        /**
        * wpmu_shared_content
        */
        class wpmu_shared_content
        {

                static $main_site_id;
                static $current;


                //class constructor
                public function __construct($main_id = 1);
                {
                        global $blog_id;
                        $this->main_site_id = $main_id
                        $this->current =  $blog_id;
                        //only register the post type to the main side
                        if (is_main_site($this->main_site_id) && is_super_admin())  
                                add_action( 'init', array($this,'register_shared_content' ));

                        add_shortcode('sh',array($this,'load_shared_content'));
                        add_shortcode('SH',array($this,'load_shared_content'));
                }

                //register custom post type shared content
                public function register_shared_content() {
                        $labels = array( 
                                'name' => _x( 'Shared Content', 'shared_content' ),
                                'singular_name' => _x( 'shared_content', 'shared_content' ),
                                'add_new' => _x( 'Add New', 'shared_content' ),
                                'add_new_item' => _x( 'Add New shared_content', 'shared_content' ),
                                'edit_item' => _x( 'Edit shared_content', 'shared_content' ),
                                'new_item' => _x( 'New shared_content', 'shared_content' ),
                                'view_item' => _x( 'View shared_content', 'shared_content' ),
                                'search_items' => _x( 'Search Shared Content', 'shared_content' ),
                                'not_found' => _x( 'No shared content found', 'shared_content' ),
                                'not_found_in_trash' => _x( 'No shared content found in Trash', 'shared_content' ),
                                'parent_item_colon' => _x( 'Parent shared_content:', 'shared_content' ),
                                'menu_name' => _x( 'Shared Content', 'shared_content' ),
                        );

                        $args = array( 
                                'labels' => $labels,
                                'hierarchical' => false,
                                'description' => 'Content to be shared with all sites but managed form main installation only.',
                                'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields' ),

                                'public' => true,
                                'show_ui' => true,
                                'show_in_menu' => true,

                                'menu_icon' => 'http://i.imgur.com/LI2B6.png',
                                'show_in_nav_menus' => true,
                                'publicly_queryable' => false,
                                'exclude_from_search' => false,
                                'has_archive' => false,
                                'query_var' => false,
                                'can_export' => true,
                                'rewrite' => false,
                                'capability_type' => 'post'
                        );
                        register_post_type( 'shared_content', $args );
                }

                //shortcode handler
                public function load_shared_content($atts,$content=null){
                        extract(shortcode_atts(
                                array('id' => 0),
                        $atts));
                        $retVal = "";
                        if ($id <= 0)
                                return $retval;

                        $shared_content = get_blog_post($this->main_site_id,$id);
                        $retVal = apply_filters('the_content',$shared_contents['post_content']);
                        return $retVal;
                }

        }//end class
}//end if

if (is_multisite())
        new wpmu_shared_content(apply_filters('wpmu_shared_content_main_site_id', 1));

/**
 * Usage:  [sh id="3"] or [SH id= 3]
 */
2
  • Great concept! A nice addition will be a meta box with a dropdown list of the Shared Content posts, coupled with a custom template. I'll leave here as a public todo, but already inserted it on my list.
    – brasofilo
    Commented Jun 6, 2012 at 20:36
  • This is a great start. One thing that I think would be a good addition (I'm adding it to my implementation) is a quick post_type check to ensure that the end user doesn't accidentally grab a Post or Page or other custom post type. As best I can tell this snippet doesn't do that right now but it wouldn't be hard to add.
    – mrwweb
    Commented Jun 24, 2013 at 18:28
2

bainternet and davemac's answers are great, if not a little heavy handed. I had a similar situation where I had like 5 blogs running, with one "master" blog that kept all of the global terms of use and privacy policy things. How I did it is like this:

  1. Within your your main blog, create your pages, then set up a nav menu called "global" that contains all the pages you want shared globally.

  2. Add the following code to your themes, wherever you want the global navigation to appear:

    if (is_multisite()) switch_to_blog(1); //if the global blog is #1
    wp_nav_menu( array( 'theme_location' => 'global' ) );
    restore_current_blog();
    
  3. You could add the above code to a widget also, if you needed it in widget form.

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.