Get all terms inside a specific taxonomy in a multisite

No way to do that in a “word press” way…

function multisite_profession_select(){
    switch_to_blog(1);
    $taxonomies = array('rsitecat');

    $check_later = array();
    global $wp_taxonomies;
    foreach($taxonomies as $taxonomy){
        if (isset($wp_taxonomies[$taxonomy])){
            $check_later[$taxonomy] = false;
        } else {
            $wp_taxonomies[$taxonomy] = true;
            $check_later[$taxonomy] = true;
        }
    }

    $args       = array('hide_empty' => false);
    $terms      = get_terms($taxonomies, $args );

    echo '<pre>';
    print_r($terms);
    echo '</pre>';


    if (isset($check_later))
        foreach($check_later as $taxonomy => $unset)
            if ($unset == true)
                unset($wp_taxonomies[$taxonomy]);

    restore_current_blog();
}

WP will check if Taxonomy exists, but on multisite blog, its only switching $table_prefix but not actually switching to blog. In this fixed code – it should trick WP to think that taxonomy registred and retrive a term from a mu blog tables. after request – you killing fake taxonomy ghosts.

P/S/

I didn’t test code.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)