繁体   English   中英

WordPress分类页面不起作用

[英]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.

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