[英]WordPress Taxonomy Page Not Working
我正在嘗試為網站的每個部分創建不同的帖子類型,但是我陷入了困境。
這是我到目前為止的內容:
function create_post_type() {
register_post_type( 'information',
array(
'labels' => array(
'name' => __( 'Information' ),
'singular_name' => __( 'Information' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'information'),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt' ),
'menu_icon' => 'dashicons-admin-post',
)
);
}
add_action( 'init', 'create_post_type' );
add_action( 'init', 'build_taxonomies', 0 );
function build_taxonomies() {
register_taxonomy(
'information',
'information',
array(
'hierarchical' => true,
'label' => 'Type',
'query_var' => 'information',
'rewrite' => array( 'slug' => 'type' )
)
);
}
它顯示在面板的左側欄中信息/添加新內容/類型
在我的網站上,我看到該帖子和帶有我已注冊的所有“類型”的邊欄。
我需要查看例如:
mywebsite.com/information/daily->列出標記有每日分類法的信息中的所有帖子。
即:mywebsite.com/customposttype/taxonomy
實際上,我有一個帶有循環的taxonomy-information.php,但它會將我發送到首頁(嘗試過taxonomy-type.php,taxonomy-information-type.php,沒有人可以使用)。
我究竟做錯了什么?
首先嘗試重新保存您的永久鏈接結構(並確保wordpress有權更改根目錄中的.htaccess文件)。
其次,我不認為將帖子類型和分類法都命名為相同的名稱,然后將其重命名是一個好主意。是否有充分的理由這樣做?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.