简体   繁体   中英

Single Taxonomy page template not working

I am trying to create a custom taxonomy page template in my wordpress theme, but it shows always archive.php though i created taxonomy-lesson_categories.php and also tried taxonomy-lesson-category.php But not of that working.

Here is my taxonomy function in functions.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');

Note : There my post_type name is CV

Anyone know the reason?

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

// I am using following code in my functions.php file and saved permalinks again in admin to take effect. Yes its working fine . I tried it.:-

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM