不会显示自定义分类标签

时间:2011-07-14 作者:Slushman

我创建了两个自定义分类法(专业和研讨会类型),它们与我的自定义帖子类型CEMB研讨会和菜单上的标签相关,而不是显示我放入的标签,而是显示“帖子标签”。

请参见此处的屏幕截图(我还没有足够的声誉来发布图片):https://picasaweb.google.com/112518288555484095597/WordPressIssues?authuser=0&authkey=Gv1sRgCNeKmKmS2J_ccQ&feat=directlink

下面是我用来创建自定义分类法的代码:

// 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\'
    )
);
我想可能是因为我没有包括所有标签,所以没有正确创建标签,所以后来我补充道:

\'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\' )
        )
以及

\'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\' )
        )
但这两种改变都没有帮助。我注意到我的自定义贴子类型也没有自定义所有标签,所以我将标签添加到该代码中,并更改菜单以反映新添加的标签,但自定义分类法无法做到这一点。我做错了什么,如何修复?

1 个回复
最合适的回答,由SO网友:Chip Bennett 整理而成

尝试更改\'labels\' 并将其传递给数组arg。此外,请检查语法:

$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 );

结束

相关推荐