[英]WordPress Taxonomy Page Not Working
I am trying to create different post types for each section of my website, but I am stuck. 我正在尝试为网站的每个部分创建不同的帖子类型,但是我陷入了困境。
This is what I have so far: 这是我到目前为止的内容:
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' )
)
);
}
It shows in the left sidebar on the panel Information / Add new / Type 它显示在面板的左侧栏中信息/添加新内容/类型
In my website I see the post and a sidebar with all 'Types' I have registered. 在我的网站上,我看到该帖子和带有我已注册的所有“类型”的边栏。
I need to see, for example: 我需要查看例如:
mywebsite.com/information/daily -> list all posts in information marked with daily taxonomy. mywebsite.com/information/daily->列出标记有每日分类法的信息中的所有帖子。
That is: mywebsite.com/customposttype/taxonomy 即:mywebsite.com/customposttype/taxonomy
Actually I have a taxonomy-information.php with a loop, but it sends me to the homepage (tried taxonomy-type.php, taxonomy-information-type.php, no one works). 实际上,我有一个带有循环的taxonomy-information.php,但它会将我发送到首页(尝试过taxonomy-type.php,taxonomy-information-type.php,没有人可以使用)。
What am I doing wrong? 我究竟做错了什么?
First try to re-save your permalink structure (and make sure wordpress has permissions to change .htaccess file in your root). 首先尝试重新保存您的永久链接结构(并确保wordpress有权更改根目录中的.htaccess文件)。
Second, I don't think its a very good idea to name both the post type and the taxonomy the same, and then renaming it's slug.. Is there any good reason to do so? 其次,我不认为将帖子类型和分类法都命名为相同的名称,然后将其重命名是一个好主意。是否有充分的理由这样做?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.