Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm intending to use the default "post tags" taxonomy to provide a common set of tags across posts and 2 custom post types (to allow for collection/aggregation by tag).

I'd like to rename the "post tags" taxonomy to something else - like "general tags' - to make it a bit clearer, especially when this taxonomy is attached to other custom post types.

So, is there any way of doing this within Wordpress, or do I do it via SQL. Also, anyone know if there is an expectation that this taxonomy exists with the nane "post tags"

share|improve this question

4 Answers 4

up vote 13 down vote accepted

The information about taxonomies is stored in the global $wp_taxonomies array. If you register a new taxonomy, it is added as an object with different properties, including the labels to use in the UI. The standard tags and categories are also registered there on each page load, with the create_initial_taxonomies() function that fires on init.

Since it is a simple array of objects, we can modify it and see what happens. The properties we are interested in are labels and label.

add_action( 'init', 'wpa4182_init');
function wpa4182_init()
{
    global $wp_taxonomies;

    // The list of labels we can modify comes from
    //  http://codex.wordpress.org/Function_Reference/register_taxonomy
    //  http://core.trac.wordpress.org/browser/branches/3.0/wp-includes/taxonomy.php#L350
    $wp_taxonomies['post_tag']->labels = (object)array(
        'name' => 'WPA 4182 Tags',
        'menu_name' => 'WPA 4182 Tags',
        'singular_name' => 'WPA 4182 Tag',
        'search_items' => 'Search WPA 4182 Tags',
        'popular_items' => 'Popular WPA 4182 Tags',
        'all_items' => 'All WPA 4182 Tags',
        'parent_item' => null, // Tags aren't hierarchical
        'parent_item_colon' => null,
        'edit_item' => 'Edit WPA 4182 Tag',
        'update_item' => 'Update WPA 4182 Tag',
        'add_new_item' => 'Add new WPA 4182 Tag',
        'new_item_name' => 'New WPA 4182 Tag Name',
        'separate_items_with_commas' => 'Separata WPA 4182 tags with commas',
        'add_or_remove_items' => 'Add or remove WPA 4182 tags',
        'choose_from_most_used' => 'Choose from the most used WPA 4182 tags',
    );

    $wp_taxonomies['post_tag']->label = 'WPA 4182 Tags';
}

I haven't checked it everywhere, and you'll probably have to change it in your theme yourself, but this seems to do what you want:

Tag metabox with new labels

share|improve this answer
    
Nice one - I'll give this a go and report back. Thanks –  anu Nov 17 '10 at 12:13
    
worked a treat. Thanks :) –  anu Nov 17 '10 at 12:49
    
exactly what i needed. didn't know about the $taxonomies global –  helgatheviking Nov 7 '11 at 21:50
    
One small issue when using this code: if I run WP 3.8.1 with DEBUG:true, I see a notice on the edit page of each tag: "Notice: Undefined property: stdClass::$view_item in /wp-includes/admin-bar.php on line 508". Indeed, if I add a "view_item" label to the list (View WPA 4182), the notice goes away. –  manu Feb 26 at 12:08

From here

// hook the translation filters
add_filter(  'gettext',  'change_post_to_article'  );
add_filter(  'ngettext',  'change_post_to_article'  );

function change_post_to_article( $translated ) {
     $translated = str_ireplace(  'Post',  'Article',  $translated );  // ireplace is PHP5 only
     return $translated;
}
share|improve this answer

Rename specific category labels:

add_action('init', 'renameCategory');
function renameCategory() {
    global $wp_taxonomies;

    $cat = $wp_taxonomies['category'];
    $cat->label = 'My Categories';
    $cat->labels->singular_name = 'My Categorie';
    $cat->labels->name = $cat->label;
    $cat->labels->menu_name = $cat->label;
    //…
}

Labels: http://codex.wordpress.org/Function_Reference/register_taxonomy#Arguments

share|improve this answer

You could remove the Categories taxonomy and then simply create your own.

In my example I've removed the post Categories taxonomy and replaced it with a Subjects taxonomy

add_action( 'init', 'unregister_taxonomy' );
function unregister_taxonomy() {
    global $wp_taxonomies;
    $taxonomy = 'category';
    if ( taxonomy_exists($taxonomy) ){
        unset( $wp_taxonomies[$taxonomy] );
    }
}

function article_subjects() {
    $labels = array(
        'name'                       => _x( 'Subjects', 'Taxonomy General Name', 'dc' ),
        'singular_name'              => _x( 'Subject', 'Taxonomy Singular Name', 'dc' ),
        'menu_name'                  => __( 'Subjects', 'dc' ),
        'all_items'                  => __( 'All Items', 'dc' ),
        'parent_item'                => __( 'Parent Item', 'dc' ),
        'parent_item_colon'          => __( 'Parent Item:', 'dc' ),
        'new_item_name'              => __( 'New Subject', 'dc' ),
        'add_new_item'               => __( 'Add New Item', 'dc' ),
        'edit_item'                  => __( 'Edit Item', 'dc' ),
        'update_item'                => __( 'Update Item', 'dc' ),
        'separate_items_with_commas' => __( 'Separate items with commas', 'dc' ),
        'search_items'               => __( 'Search Items', 'dc' ),
        'add_or_remove_items'        => __( 'Add or remove items', 'dc' ),
        'choose_from_most_used'      => __( 'Choose from the most used items', 'dc' ),
        'not_found'                  => __( 'Not Found', 'dc' ),
    );
    $args = array(
        'labels'                     => $labels,
        'hierarchical'               => false,
        'public'                     => true,
        'show_ui'                    => true,
        'show_admin_column'          => true,
        'show_in_nav_menus'          => true,
        'show_tagcloud'              => true,
    );
    register_taxonomy( 'article_subjects', array( 'post' ), $args );
}
add_action( 'init', 'article_subjects', 0 );
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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