2015-11-04 118 views
1

我正在wordpress站点上构建FAQ部分。我有一个称为faq的自定义发布类型,并且有一个名为faq-category的自定义分类。我还在使用名为Custom Post Type Permalinks的插件。Wordpress自定义帖子和分类标签404

我试图实现以下固定链接结构:

  • domain.com/faq
  • domain.com/faq/category
  • domain.com/faq/category/question-title

到目前为止,我似乎只能得到2/3的工作。所以下面的例子给我:

  • domain.com/faq
  • domain.com/faq/category

和`domain.com/faq/category/question-title一个404

如果我更改:'slug' => 'faq''slug' => ''关于我重新编写的自定义分类。我在分类页面上得到了404错误,并且单个帖子将工作。

感谢

/** 
* Custom taxonomys 
*/ 
function create_faq_tax() { 
    register_taxonomy(
     'faq-category', 
     'faq', 
     array(
      'label' => __('Category'), 
      'rewrite' => array('slug' => 'faq', 'with_front' => false, 'hierarchical' => true), 
      'hierarchical' => true 
     ) 
    ); 
} 

add_action('init', 'create_faq_tax'); 


/** 
* FAQ Custom post type 
*/ 
function create_faq_post_type() { 
    register_post_type('faq', 
     array(
      'labels' => array(
       'name' => __('FAQ\'s'), 
       'singular_name' => __('FAQ'), 
       'add_new' => 'Add new FAQ', 
       'add_new_item' => 'Add a new FAQ', 
       'edit_item' => 'Edit FAQ', 
      ), 
      'public' => true, 
      'publicly_queryable' => true, 
      'hierarchical' => true, 
      'taxonomies' => array('faq-category'), 
      'has_archive' => true, 
      'menu_icon' => 'dashicons-feedback', 
      'rewrite' => array('slug' => 'faq', 'with_front' => false), 
      'query_var' => true, 
     ) 
    ); 


} 
add_action('init', 'create_faq_post_type'); 
+0

我遇到了与我自己的自定义帖子类型(啤酒)和类似的分类(啤酒/风格)相同的问题。如果我将slug设置为'beer/style',它会抛出一个404,但是如果我将slug设置为'style',那么纳税页就可以工作,尽管不在我期望的永久链接结构中。 – Quantastical

回答

0

在创建新的自定义柱式或分类,你将不得不重新生成永久链接:可湿性粉剂管理员/选项 - permalink.php。推“保存更改”按钮

+0

我已经这样做了,并没有什么区别。 –

+0

您是否尝试在此处生成自定义帖子类型(https://generatewp.com/post-type/)? – vol4ikman

+0

我刚刚尝试过这个工具。仍然是同样的问题。 –

相关问题