我正在开发的主题基本上是一个公文包,其中的项目是自定义的帖子类型,它们被划分为类别(自定义分类法)。以下是我如何定义这两者:
$labels = array(
\'name\' => _x(\'My Portfolio\', \'post type general name\'),
\'singular_name\' => _x(\'Portfolio Item\', \'post type singular name\'),
\'add_new\' => _x(\'Add New\', \'portfolio item\'),
\'add_new_item\' => _x(\'Add New Portfolio Item\', \'add new portfolio item\'),
\'edit_item\' => _x(\'Edit Portfolio Item\', \'edit portfolio item\'),
\'new_item\' => _x(\'New Portfolio Item\', \'new portfolio item\'),
\'view_item\' => __(\'View Portfolio Item\'),
\'search_items\' => __(\'Search Portfolio\'),
\'not_found\' => __(\'Nothing found\'),
\'not_found_in_trash\' => __(\'Nothing found in Trash\'),
\'parent_item_colon\' => \'\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'query_var\' => true,
\'menu_icon\' => null,
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array(null)
);
register_post_type(\'portfolio\', $args);
register_taxonomy(\'project_category\', array(\'portfolio\'), array(
\'hierarchical\' => true,
\'label\' => "Project Categories",
\'singular_label\' => "Project Category",
\'rewrite\' => true
));
所以在主页上我列出了所有的税收条款。“project\\u category”,我想要一个单一术语的模板文件(例如,“jQuery插件”或“WordPress主题”),在这里我可以列出所有使用该术语的项目。
我查看了WP模板层次结构,我认为我需要的模板是
taxonomy-$taxonomy.php
我的文件名为taxonomy-project\\u category。php,但它找不到它。我还尝试了分类法。php,术语。php,存档。php。。。没有成功。我认为问题在于链接:
<a href="<?php echo $term->slug; ?>"><?php echo $term->name; ?></a>
有什么想法吗?干杯