$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Custom taxonomy labels won't display|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Custom taxonomy labels won't display

matteradmin8PV0评论

I created two custom taxonomies (Majors and Seminar Types) related my custom post type CEMB Seminar and the labels on the menu, instead of showing the labels I put in are showing "Post Tags".

See a screenshot here (I don't have enough reputation to post pics yet): ;authkey=Gv1sRgCNeKmKmS2J_ccQ&feat=directlink

Here's the code I used to create the custom taxonomies:

// Register the Majors taxonomy
register_taxonomy( 'cemb_seminar_major', array( 'cemb_seminar' ), $major_args );

// Register the Seminar Types taxonomy
register_taxonomy( 'cemb_seminar_type', array( 'cemb_seminar' ), $types_args );

// Set up the Majors arguments
$major_args = array( 
    'rewrite' => array(
        'slug' => 'major',
        'with_front' => 'false'
    ),
    'labels' => array(
        'name' => 'Majors',
        'singular_name' => 'Major'
    )       
);

// Set up the Types arguments
$types_args = array( 
    'rewrite' => array(
        'slug' => 'seminar-type',
        'with_front' => 'false'
    ),
    'labels' => array(
        'name' => 'Seminar Types',
        'singular_name' => 'Seminar Type'
    )
);

I thought maybe since I didn't include all the labels, it wasn't creating the labels correctly, so I later added:

'labels' => array(
            'name' => _x( 'Majors', 'taxonomy general name' ),
            'singular_name' => _x( 'Major', 'taxonomy singular name' ),
            'search_items' => __( 'Search Majors' ),
            'popular_items' => __( 'Popular Majors' ),
            'all_items' => __( 'All Majors' ),
            'edit_item' => __( 'Edit Major' ),
            'update_item' => __( 'Update Major' ),
            'add_new_item' => __( 'Add New Major' ),
            'new_item_name' => __( 'New Major' ),
            'separate_items_with_commas' => __( 'Separate majors with commas' ),
            'add_or_remove_items' => __( 'Add or remove majors' ),
            'choose_from_most_used' => __( 'Choose from the most popular majors' )
        )

and

'labels' => array(
            'name' => _x( 'Seminar Types', 'taxonomy general name' ),
            'singular_name' => _x( 'Seminar Type', 'taxonomy singular name' ),
            'search_items' => __( 'Search Seminar Types' ),
            'popular_items' => __( 'Popular Seminar Types' ),
            'all_items' => __( 'All Seminar Types' ),
            'edit_item' => __( 'Edit Seminar Type' ),
            'update_item' => __( 'Update Seminar Type' ),
            'add_new_item' => __( 'Add New Seminar Type' ),
            'new_item_name' => __( 'New Seminar Type' ),
            'separate_items_with_commas' => __( 'Separate seminar types with commas' ),
            'add_or_remove_items' => __( 'Add or remove seminar types' ),
            'choose_from_most_used' => __( 'Choose from the most popular seminar types' )
        )

But neither changed helped. I noticed my custom post type also didn't have all the labels customized, so I added the labels to that code and the menu changed to reflect the newly added labels, but the custom taxonomies won't do that. What did I do wrong and how do I fix it?

I created two custom taxonomies (Majors and Seminar Types) related my custom post type CEMB Seminar and the labels on the menu, instead of showing the labels I put in are showing "Post Tags".

See a screenshot here (I don't have enough reputation to post pics yet): https://picasaweb.google/112518288555484095597/WordPressIssues?authuser=0&authkey=Gv1sRgCNeKmKmS2J_ccQ&feat=directlink

Here's the code I used to create the custom taxonomies:

// Register the Majors taxonomy
register_taxonomy( 'cemb_seminar_major', array( 'cemb_seminar' ), $major_args );

// Register the Seminar Types taxonomy
register_taxonomy( 'cemb_seminar_type', array( 'cemb_seminar' ), $types_args );

// Set up the Majors arguments
$major_args = array( 
    'rewrite' => array(
        'slug' => 'major',
        'with_front' => 'false'
    ),
    'labels' => array(
        'name' => 'Majors',
        'singular_name' => 'Major'
    )       
);

// Set up the Types arguments
$types_args = array( 
    'rewrite' => array(
        'slug' => 'seminar-type',
        'with_front' => 'false'
    ),
    'labels' => array(
        'name' => 'Seminar Types',
        'singular_name' => 'Seminar Type'
    )
);

I thought maybe since I didn't include all the labels, it wasn't creating the labels correctly, so I later added:

'labels' => array(
            'name' => _x( 'Majors', 'taxonomy general name' ),
            'singular_name' => _x( 'Major', 'taxonomy singular name' ),
            'search_items' => __( 'Search Majors' ),
            'popular_items' => __( 'Popular Majors' ),
            'all_items' => __( 'All Majors' ),
            'edit_item' => __( 'Edit Major' ),
            'update_item' => __( 'Update Major' ),
            'add_new_item' => __( 'Add New Major' ),
            'new_item_name' => __( 'New Major' ),
            'separate_items_with_commas' => __( 'Separate majors with commas' ),
            'add_or_remove_items' => __( 'Add or remove majors' ),
            'choose_from_most_used' => __( 'Choose from the most popular majors' )
        )

and

'labels' => array(
            'name' => _x( 'Seminar Types', 'taxonomy general name' ),
            'singular_name' => _x( 'Seminar Type', 'taxonomy singular name' ),
            'search_items' => __( 'Search Seminar Types' ),
            'popular_items' => __( 'Popular Seminar Types' ),
            'all_items' => __( 'All Seminar Types' ),
            'edit_item' => __( 'Edit Seminar Type' ),
            'update_item' => __( 'Update Seminar Type' ),
            'add_new_item' => __( 'Add New Seminar Type' ),
            'new_item_name' => __( 'New Seminar Type' ),
            'separate_items_with_commas' => __( 'Separate seminar types with commas' ),
            'add_or_remove_items' => __( 'Add or remove seminar types' ),
            'choose_from_most_used' => __( 'Choose from the most popular seminar types' )
        )

But neither changed helped. I noticed my custom post type also didn't have all the labels customized, so I added the labels to that code and the menu changed to reflect the newly added labels, but the custom taxonomies won't do that. What did I do wrong and how do I fix it?

Share Improve this question asked Jul 14, 2011 at 17:33 SlushmanSlushman 493 silver badges13 bronze badges 1
  • Your args need to be defined before registering the taxonomies, that is most definately your issue if the args are being defined after - as in the above code. – t31os Commented Jul 15, 2011 at 8:21
Add a comment  | 

1 Answer 1

Reset to default 1

Try changing 'labels' to an array arg, and passing that. Also, check for syntax:

$labels => array(
    'name' => _x( 'Seminar Types', 'taxonomy general name' ),
    'singular_name' => _x( 'Seminar Type', 'taxonomy singular name' ),
    'search_items' => __( 'Search Seminar Types' ),
    'popular_items' => __( 'Popular Seminar Types' ),
    'all_items' => __( 'All Seminar Types' ),
    'edit_item' => __( 'Edit Seminar Type' ),
    'update_item' => __( 'Update Seminar Type' ),
    'add_new_item' => __( 'Add New Seminar Type' ),
    'new_item_name' => __( 'New Seminar Type' ),
    'separate_items_with_commas' => __( 'Separate seminar types with commas' ),
    'add_or_remove_items' => __( 'Add or remove seminar types' ),
    'choose_from_most_used' => __( 'Choose from the most popular seminar types' )
);
// Set up the Types arguments
$types_args = array( 
    'rewrite' => array(
        'slug' => 'seminar-type',
        'with_front' => 'false'
    ),
    'labels' => $args
);
// Register the Seminar Types taxonomy
register_taxonomy( 'cemb_seminar_type', array( 'cemb_seminar' ), $types_args );

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far