• I have custom taxonomies across a WordPress multisite install (same taxonomies on all sites). I’m trying to add some custom meta boxes to each of these taxonomies (same meta boxes on all sites).

    I’m using the following plugin to activate a global meta tags and add the appropriate table in the database: http://wordpress.org/extend/plugins/simple-meta-tags/

    The meta boxes display fine across all sites, and save ok on the main site, but on sub-sites no inputs will save. I assume this is because no blog_id or global variable is declared in the save function, but i’m a bit confused how to add/do this.

    So far I have the following test code placed in a master custom functions file which all the bogs can access:

    add_action('taxonomyname_add_form_fields', 'taxonomyname_metabox_add', 10, 1);
    add_action('taxonomyname_edit_form_fields', 'taxonomyname_metabox_edit', 10, 1);    
    
    function taxonomyname_metabox_add($tag) { ?>
    <h3>Meta Box Info Title</h3>
        <div class="form-field">
            <label for="extrafield1"><?php _e('Extra Field 1') ?></label>
            <input name="extrafield1" id="extrafield1" type="text" value="" size="40" aria-required="true" />
        </div>
        <div class="form-field">
            <label for="extrafield2"><?php _e('Extra Field 2') ?></label>
            <input name="extrafield2" id="image2" type="text" value="" size="40" aria-required="true" />
        </div>
    <?php }     
    
    function taxonomyname_metabox_edit($tag) { ?>
    <h3>Meta Box Info Title</h3>
        <table class="form-table">
            <tr class="form-field">
            <th scope="row" valign="top">
                <label for="extrafield1"><?php _e('Extra Field 1'); ?></label>
            </th>
            <td>
                <input name="extrafield1" id="extrafield1" type="text" value="<?php echo get_term_meta($tag->term_id, 'extrafield1', true); ?>" size="40" aria-required="true" />
            </td>
            </tr>
            <tr class="form-field">
            <th scope="row" valign="top">
                <label for="extrafield2"><?php _e('Extra Field 2'); ?></label>
            </th>
            <td>
                <input name="extrafield2" id="extrafield2" type="text" value="<?php echo get_term_meta($tag->term_id, 'extrafield2', true); ?>" size="40" aria-required="true" />
            </td>
            </tr>
        </table>
    <?php }
    
    add_action('created_taxonomyname', 'save_taxonomyname_metadata', 10, 1);
    add_action('edited_taxonomyname', 'save_taxonomyname_metadata', 10, 1);
    
    function save_taxonomyname_metadata($term_id){
    {
    
        if (isset($_POST['extrafield1']))
            update_term_meta( $term_id, 'extrafield1', $_POST['extrafield1']);
    }
    {
        if (isset($_POST['extrafield2']))
            update_term_meta( $term_id, 'extrafield2', $_POST['extrafield2']);
    }
    }

    Can anyone assist with getting this working for all the blogs/sites please?

    I have been following this guide so far: http://www.wpmods.com/adding-metadata-taxonomy-terms/

    Thanks,
    Rob

  • The topic ‘Multisite Taxonomy Meta Boxes’ is closed to new replies.