我使用的是一种自定义分类法,术语是slug“托儿所”。我还使用了一个带有slug“托儿所”的页面。我可以很好地查看页面,但尝试查看“托儿所”术语归档页面get_term_link()
将我重定向回页面。
因此,从本页:
/所有班级/托儿所
我有一个到班级/托儿所的链接
但点击链接只会将我重定向回所有课程/托儿所
而不是显示归档页面。
如何查看该术语的存档页?
编辑:根据要求编辑代码。
class Taxonomy {
public $taxonomies;
function __construct() {
$this->taxonomies = $this->set_taxonomies();
add_action(\'wp_loaded\', array($this, \'register_taxonomies\'));
}
// Register our taxonomies
public function register_taxonomies() {
register_taxonomy(\'class\', \'post\', $this->taxonomies[\'class\']);
}
private function set_taxonomies() {
return array(
\'class\' => array(
\'public\' => true,
\'show_tagcloud\' => false,
\'hierarchical\' => true,
\'rewrite\' => array(
//\'slug\' => \'class-blog\',
\'with_front\' => false,
),
\'labels\' => array(
\'name\' => _x( \'Classes\', \'taxonomy general name\', \'pys\' ),
\'singular_name\' => _x( \'Class\', \'taxonomy singular name\', \'pys\' ),
\'search_items\' => __( \'Search Classes\', \'pys\' ),
\'popular_items\' => __( \'Popular Classes\', \'pys\' ),
\'all_items\' => __( \'All Classes\', \'pys\' ),
\'parent_item\' => null,
\'parent_item_colon\' => null,
\'edit_item\' => __( \'Edit Class\', \'pys\' ),
\'update_item\' => __( \'Update Class\', \'pys\' ),
\'add_new_item\' => __( \'Add New Class\', \'pys\' ),
\'new_item_name\' => __( \'New Class Name\', \'pys\' ),
\'separate_items_with_commas\' => __( \'Separate classes with commas\', \'pys\' ),
\'add_or_remove_items\' => __( \'Add or remove classes\', \'pys\' ),
\'choose_from_most_used\' => __( \'Choose from the most used classes\', \'pys\' ),
\'not_found\' => __( \'No classes found.\', \'pys\' ),
\'menu_name\' => __( \'Classes\', \'pys\' ),
),
), // end of \'channel\' taxonomy
);
}
}
略微修改版本以删除不相关的内容。分类法类在执行函数时实例化。php已运行。