0

In my wordpress multisite install I have a case studies custom post type set up and they have custom taxonomies. This is all working well, however I need to create different taxonomies for the case studies custom post type across different sites.

I can see many articles about sharing/global taxonomies but nothing about having different taxonomies on different sites.

Is this possible?

1 Answer 1

1

Sure, you can.

Each site in multisite is completely independent, so you can have completely different CPTs, taxonomies and... everything.

The problem is that if you register the CPT via a plugin, and you enable it in all sites (or network-activate it) and you use the same plugin to register taxonomies, you'll have same taxonomies everywhere.

The simplest thing would be to create a plugin to register the CPT and taxonomies that you want in all sites (if any), then network-activate it.

After that, you can create different plugin for different taxonomies.

For example, if you "main" plugin does:

add_action('init', function() {
   register_post_type( 'mycpt', [ ... ] );
});

You can have another plugin that does:

add_action('registered_post_type', function($cpt) {
   if ( $cpt !== 'mycpt' ) {
       return;
   }
   register_taxonomy( 'taxonomy_1', 'mycpt', [ ... ] );
   register_taxonomy( 'taxonomy_2', 'mycpt', [ ... ] );
});

then, another that does:

add_action('registered_post_type', function($cpt) {
   if ( $cpt !== 'mycpt' ) {
       return;
   }
   register_taxonomy( 'taxonomy_3', 'mycpt', [ ... ] );
});

So you can activate on specific sites the plugins that activate the taxonomies you need.

Thanks to the fact that you use registered_post_type action, if the "main" plugin is not activated, even if the secondary plugin are activated they will do nothing.

2
  • Thanks for the suggestion @gmazzap - the custom post types are setup in the code and so are the taxonomies, I'm assuming if I set the custom taxonomies in the code they will be available globally but with your approach they are individual to each site, is that correct? Sep 27, 2018 at 10:55
  • Yes @NeelamKhan if custom taxonomies are set in different plugin and you enable different plugin in different websites, you'll end up having taxonomies where you need them.
    – gmazzap
    Sep 28, 2018 at 13:15

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.