SH Global Posts

Please Note: This is a WordPress MU plugin, do not install it on a standalone version of WordPress. WPMU and this plugin require some PHP knowledge. It’s not intended for end users. You have been warned! 🙂

Intro

This plugin requires the Real Global Terms plugin to be installed.

This plugin will make a copy of every post, on every blog, and put all those copies into one, single blog. It will copy the post as well as the post’s tags and categories. This means that you can search the single blog for all posts across all blogs across your whole site. Likewise for categories and tags. This also means your global blog feed will include all the posts for your whole site.

Each of the copied posts links back to the original post’s permalink. This means the global feed points to each individual post on each individual blog. The plugin also redirects any requests for individual posts on the global blog to the original blog. This should avoid the duplicate content penalty, and ensure all your comments / trackbacks / pingbacks / etc are in one place.

When the post is copied to the global posts, comments and pingbacks are automatically closed, as they should go to the original post.

Configuration

By default the global blog is blog ID 1, which is normally the main site. However, you can change that. Simply add this line to your wp-config.php file:

define('GLOBAL_POSTS_BLOG_ID', 1);

Obviously you need to change 1 to be the ID of the blog you’d like to be the global blog! 🙂

Alternatively you can set the default blog in a site option with the name ‘global_posts_blog_id’. Currently (May 2008) there is no easy way to set site options from the admin interface, so the first option is probably easier. However, if you want to set it manually, the SQL is probably:

INSERT INTO wp_sitemeta (site_id, meta_key, meta_value) VALUES (1,'global_posts_blog_id','XXX');

Again, obviously you need to change XXX to the be the ID of the global blog. If you’re not using ‘wp_’ as your table prefix, you will also need to change the table name. If this stuff is all beyond you, this plugin is not for you I’m afraid.

MU Plugins

This plugin must be installed for all blogs on your site, so it must be in the ‘wp-content/mu-plugins’ directory. If you install it in the ‘wp-content/plugins’ directory the world may very well end. 🙂

Support

I’m happy to answer developer questions here and there, but I can’t provide end user support for this plugin. If you can’t read the code and understand what it does, I’d suggest avoid using the plugin. If you ask me very nicely and promise to send me chocolate cake, I might be able to help. But it’s strictly at your own risk. Please post any questions in the comments on this page.

Download

If you have made it this far and still want to proceed, please go ahead and download the code here. I’d strongly recommend you subscribe to this feed to be kept informed about updates to the plugin.

Gratitude

This plugin was created as part of my work with SmartHippo. If you’d like to show gratitude, please register with SmartHippo and post a rate.

Changelog

0.2.2 – Added a generic filter to allow blog exclusion
0.2.1 – Added ignore mature option
0.2 – First public release

21 thoughts on “SH Global Posts”

  1. this line is bringing my site down.
    ‘define ( ‘REAL_GLOBAL_TERMS_INSTALLED’, false );’
    when its set to false, my site goes down. when set to true, the site comes up. here are a couple of lines from my DB

    [28-May-2008 18:38:36] WordPress database error Table ‘database.wp_site_term_taxonomy’ doesn’t exist for query INSERT INTO wp_site_term_taxonomy ( term_id, taxonomy, parent ) VALUES ( ‘14013’, ‘category’, ‘0’ ) made by global_term_taxonomy [28-May-2008 18:38:36] WordPress database error: [Table 'database.wp_site_term_taxonomy' doesn't exist]

    [28-May-2008 18:38:36] WordPress database error Duplicate entry ‘229-0’ for key 1 for query UPDATE wp_29_term_relationships SET term_taxonomy_id = ” WHERE term_taxonomy_id = ‘432’ made by global_term_taxonomy [28-May-2008 18:38:36] WordPress database error: [Duplicate entry '229-0' for key 1] UPDATE wp_29_term_relationships SET term_taxonomy_id = '' WHERE term_taxonomy_id = '432'

  2. @demonicume: You don’t want it set to false, that means that the plugin has not been installed. You’d only ever want to set it to true. As soon as you hit one page on one site, the plugin will do all it’s installation stuff. So you’d only ever want it set to true after the tables have been created.

    Does your database user have create table privileges? It looks like the new tables are not being created properly. You could try creating them manually, but the plugin should auto create them on first run. Do you have any logs with CREATE TABLE queries?

  3. Great plugin. thank you. if i use this method will i be able to search custom fields using a search custom-fields plugin? i.e. does the plugin import meta data as well?

  4. @george: No, it doesn’t currently copy metadata. It wouldn’t be a major task to add that to the plugin though. It copies the term_relationships, so it could copy post_meta in the same way.

  5. @george: You could add it to the plugin quite easily. It’s something I could add if I had time, but I’m not sure when that would be. I published these plugins to put them out there, I’m not looking to maintain them. If you do add the functionality, I’ll be happy to include it in the original plugin with a credit.

  6. as of now when i set it up the “global posts blog” puts all the posts under uncategorized(including from sub blogs). is this how it is supposed to be or am i doing something wrong? tags from sub blogs are not appearing either. any thoughts?

  7. @george: All the posts are appearing under uncategorized on the global blog? That’s definitely not right.

    I’d suggest debugging as follows:
    1) Are the site_terms and site_term_taxonomy tables being populated?
    2) Are the IDs being kept in sync with those tables and the individual blog terms / term_taxonomy tables?
    3) Is the global blog’s term_relationships table being populated?

  8. excuse my ignorance in this subject. I’m thinking that your plugin will be right for what I need to do, which is intelligently gather posts from many sub blogs in MU and post the results in one main blog. I’d like to add moderation (http://wpmu.org/collaboration-emails-plugin-wordpress-mu/) as well as view posts by category. Does the new wordpress update already do this? Or does this plugin (http://wpmudev.org/project/AHP-Sitewide-Recent-Posts-for-WPMU) differ very much from yours. thanks very much!

    Admin: Comment edited, link added as per follow up comment.

  9. @Deryk: I’m not familiar with the other plugin, so I’m not sure how they compare.

    The plugin will allow you to push all posts from all your blogs onto one single blog. Then you can do any of the usual stuff with those posts on the global blogs (show tag pages, search, etc).

  10. hey callum, thanks for the reply. the other plugin works quite well for new sites in that on every post creation or save it copies the post to a central blog. however it does not work well if you need to convert an existing site. my question: does your plugin work with the latest version of wpmu 2.6? and does it copy the posts or just reference them somehow within the existing blog? ie. how does it deal with duplication? many thanks.

  11. @Deryk: The plugin creates a duplicate post on the main blog. The posts are linked by their guid. The plugin also pushes updates to the posts. So if a post is changed, it will be updated on the main blog. I believe the plugin does work with the latest version of WPMU, but I haven’t thoroughly tested it yet.

  12. @Guas: No need to create tables. However, I’d strongly recommend you read and understand the code before using it. I publish it here really as a source for developers. The plugins are not very “polished”. 🙂

  13. Hi 🙂 I have uploaded this to my site in the correct folder but am not seeing anything. I now cannot create categories either LOL

    So I have the plugin installed I should imagine but there are no settings for it and my category making is now defunct. Where SHOULD the settings be?

    Any help gratefully received 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *