Setting up a WP multisite instance – the client has an existing ontology / set of categories that they want to classify all content across the set of blogs. Also the desire is that any new categories would be added at the ‘network blog’ level and synced to the other blogs.
What’s the best way of doing this?
This will run whenever a category is added on the main site. A few caveats/points worth mentioning;
Oh, sunday procrastination…
https://github.com/maugly/Network-Terminator
network
affected
This is something I’ve done in a last few hours and I have no time for more testing now. Anyway – it works for me! .)
Give it a try. There’s also a ‘test run’ feature implemented so you can check the result before actually doing something.
Update -> Screenshots:
Before action:
After test run:
The plugin linked above adds user interface but pretty much everything important happens in this function:
I will come back and edit this with more info later (if needed).
It is far from perfect (read known issues in the plugin head).
Any feedback appreciated!
TheDeadMedic’s answer looks good, but I ended up taking a different approach to the problem. Instead of duplicating the same terms across the many sites, I instead made the other sites use the home site’s tables for terms.
This replaces the table name
wp_2_terms
withwp_terms
, etc. You should of course check in your database to make sure of the exact name of the tables, which might be different if you change your prefix.You can run this from either a plugin or a theme (though I recommend a plugin). I may get round to publishing a plugin to do this at some point. There are two downsides to this approach:
This approach is flexible – it can be adapted to pull categories from any blog, not just the central one.
Update: I’ve made this into a plugin, which can be activated site-wide if you need it to be: MU Central Taxonomies
Yes this is possible. I built a plugin like this for WPMU ages ago (http://natureofmind.org/30/default-categories-for-new-blogs/ but no longer supported) more up-to-date would be the following two plugins: http://wordpress.org/extend/plugins/wpmu-new-blog-defaults/ and http://premium.wpmudev.org/project/new-blog-template
Complementing @Marcus Downing answer, I’ve added a protection to prevent deleting the tables when deleting a MU site.
This is intended to be used as a mu-plugin. If you want to use it elsewhere, change the “muplugins_loaded” hook to “plugins_loaded”.