我有一个自定义的帖子类型,叫做project
调用自定义分类法tagportfolio
我使用此代码生成以下两个:
add_action(\'init\', \'project_custom_init\');
/*-- Custom Post Init Begin --*/
function project_custom_init()
{
$labels = array(
\'name\' => _x(\'Projects\', \'post type general name\'),
\'singular_name\' => _x(\'Project\', \'post type singular name\'),
\'add_new\' => _x(\'Add New\', \'project\'),
\'add_new_item\' => __(\'Add New Project\'),
\'edit_item\' => __(\'Edit Project\'),
\'new_item\' => __(\'New Project\'),
\'view_item\' => __(\'View Project\'),
\'search_items\' => __(\'Search Projects\'),
\'not_found\' => __(\'No projects found\'),
\'not_found_in_trash\' => __(\'No projects found in Trash\'),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Project\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array(\'title\',\'editor\',\'author\',\'thumbnail\',\'excerpt\',\'comments\')
);
// The following is the main step where we register the post.
register_post_type(\'project\',$args);
// Initialize New Taxonomy Labels
$labels = array(
\'name\' => _x( \'Tags\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Tag\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Types\' ),
\'all_items\' => __( \'All Tags\' ),
\'parent_item\' => __( \'Parent Tag\' ),
\'parent_item_colon\' => __( \'Parent Tag:\' ),
\'edit_item\' => __( \'Edit Tags\' ),
\'update_item\' => __( \'Update Tag\' ),
\'add_new_item\' => __( \'Add New Tag\' ),
\'new_item_name\' => __( \'New Tag Name\' ),
);
// Custom taxonomy for Project Tags
register_taxonomy(\'tagportfolio\',array(\'project\'), array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'tag-portfolio\' ),
));
}
/*-- Custom Post Init Ends --*/
但是当我使用
get_terms()
函数它没有显示任何分类
然后使用以下功能:
get_terms("tagportfolio",array(\'hide_empty\'=>0));
它也没有显示我的任何分类法