Extra Meta Data for WordPress Multisite Taxonomy

Turns out that the function above actually works fine.

The issue is that the plugin (Simple Terms Meta) doesn’t create tables for each site, only the main site.

I’ve managed to modify the plugin so that when it’s activated it now creates a table for each site and it appears to be working fine and saving details for each site now.

If anyone else needs to do the same, replace lines 31-59 of the plugin (Simple Terms Meta) with the following code (and of course use the functions above as a basis for creating your own meta boxes for taxonomies). I’d also advise anyone attempting this to read this article for guidance on this too – http://www.wpmods.com/adding-metadata-taxonomy-terms/

/* Network Activation to Install Tables on all Sites */
register_activation_hook( __FILE__, 'simple_term_meta_install' );
function simple_term_meta_install() {
    global $wpdb;

    if (function_exists('is_multisite') && is_multisite()) {
        // check if it is a network activation - if so, run the activation function for each blog id
        if (isset($_GET['networkwide']) && ($_GET['networkwide'] == 1)) {
                    $old_blog = $wpdb->blogid;
            // Get all blog ids
            $blogids = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM $wpdb->blogs"));
            foreach ($blogids as $blog_id) {
                switch_to_blog($blog_id);
                _simple_term_meta_install();
            }
            switch_to_blog($old_blog);
            return;
        }   
    } 
    _simple_term_meta_install();        
}

/* End Network Activation to Install Tables on all Sites*/

/* Individual Activation to Install on Selected Sites */
function _simple_term_meta_install() {
    // Create term metadata table if necessary
    global $wpdb;
        $table_name = $wpdb->prefix . $type . 'termmeta';
    if ($wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'") != $table_name) {
        simple_term_meta_table_creation($table_name, $type);
        }
}
/* End Individual Activation to Install on Selected Sites */

function simple_term_meta_table_creation()
{
    // setup custom table

    global $wpdb;
    $table_name = $wpdb->prefix . 'termmeta';
    if( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name ) :

        $sql = "CREATE TABLE " . $table_name . " (
          meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
          term_id bigint(20) unsigned NOT NULL DEFAULT '0',
          meta_key varchar(255) DEFAULT NULL,
          meta_value longtext,
          PRIMARY KEY (meta_id),
          KEY term_id (term_id),
          KEY meta_key (meta_key)     
        );";

        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
        dbDelta($sql);

    endif;

    update_option( "simple_term_meta_db_version", '0.9' );
}

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