单个分类页面模板不起作用



我正在尝试在我的wordpress主题中创建自定义分类页面模板,但它始终显示存档.php尽管我创建了分类法lesson_categories.php并尝试了分类法课程类别.php但这不是有效的。

这是我在函数中的分类函数.php :

function cv_themes_taxonomy() {  
register_taxonomy(  
'lesson_categories',  //The name of the taxonomy.  
'cv',        //post type name
array(  
'hierarchical' => true,  
'label' => 'Lesson Category',  //Display name
'query_var' => true,
'rewrite' => array(
'slug' => 'lesson-category', 
'with_front' => true 
)
)  
);  
}  
add_action( 'init', 'cv_themes_taxonomy');

注意:我的post_type名字是CV

有人知道原因吗?

您需要阅读 WordPress.org 上的 https://developer.wordpress.org/themes/template-files-section/taxonomy-templates/分类模板文章以获取该信息。

//我在我的函数.php文件中使用以下代码,并在 admin 中再次保存永久链接以生效。是的,它工作正常.我试过了。

function cv_themes_taxonomy() {  
register_taxonomy(  
'lesson_categories',  //The name of the taxonomy.  
'cv',        //post type name
array(  
'hierarchical' => true,  
'label' => 'Lesson Category',  //Display name
'query_var' => true,
'rewrite' => array(
'slug' => 'lesson-category', 
'with_front' => true 
)
)  
);  
}  
add_action( 'init', 'cv_themes_taxonomy');

最新更新