[英]category-slug.php not working
這是我的代碼:
$config = array(
'labels' => $genre_labels,
'hierarchical' => true,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'htfiles-genre' ),
);
register_taxonomy('htfiles_genre', array('htfiles'), $config);
我在主題phpfile中創建:
Category-htfiles-genre.php
category-{slug}.php
–如果類別的標簽是htfiles-genre,則WordPress應該尋找category-htfiles-genre.php。 但是他沒有。
謝謝你的幫助!
您發布的代碼用於注冊自定義分類法,該分類法遵循與常規類別不同的命名結構。
要顯示分類法的模板文件,您需要使用taxonomy-{taxonomy}.php
。 如果要為該分類法中的給定術語創建模板,則可以使用: taxonomy-{taxonomy}-{term}.php
。
您的文件名應為: taxonomy-htfiles_genre.php
。
文檔: https : //developer.wordpress.org/themes/basics/template-hierarchy/#custom-taxonomies
//您需要再次保存永久鏈接並創建以下文件taxonomy-htfiles_genre.php。 一切都會正常。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.