0

I have a wordpress multisite network. So I want to share just some categories between subsites.

0

Here is a solution I found-

// even before any taxonmy/terms are initialized, we reset the tables
add_action( 'init', 'the_dramatist_change_tax_terms_table', 0 );
// on blog switching, we need to reset it again, so it does not use current blog's tax/terms only
// it works both on switch/restore blog
add_action( 'switch_blog', 'the_dramatist_change_tax_terms_table', 0 );

function the_dramatist_change_tax_terms_table(){
    global $wpdb;
    // change terms table to use main site's
    $wpdb->terms = $wpdb->base_prefix . 'terms';
    // change taxonomy table to use main site's taxonomy table
    $wpdb->term_taxonomy = $wpdb->base_prefix . 'term_taxonomy';
    // if you want to use a different sub sites table for sharing, you can replca e$wpdb->vbase_prefix with $wpdb->get_blog_prefix( $blog_id )
}

This code makes all the taxonomy terms( It is not taxonomy, just terms) global. I got it here. The terms can be added from any of the sub site and depending on the currently available taxonomy( registered taxonomy) of a sub site, the terms will be available there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.