Wordpress - 自定义分类模板 - 找不到页面?

时间:2017-11-10 12:59:02

标签: php wordpress

我为该帖子创建了一个自定义帖子和自定义分类,并且帖子类型和分类法都可以正常工作:

function venue_post() {
   $rewrite = array(
   'slug'                => 'venue',
   'with_front'          => true,
   'pages'               => true,
   'feeds'               => true,
   );

   $args = array(
    'label'                 => __( 'Venue', 'text_domain' ),
    'description'           => __( 'Venue Posts', 'text_domain' ),
    'labels'                => $labels,
    'supports'              => array( 'title', 'editor', 'thumbnail'),
    'taxonomies'            => array( 'locationCategories' ),
    'hierarchical'          => false,
    'public'                => true,
    'show_ui'               => true,
    'show_in_menu'          => true,
    'menu_position'         => 5,
    'menu_icon'             => 'dashicons-groups',
    'show_in_admin_bar'     => true,
    'show_in_nav_menus'     => true,
    'can_export'            => true,
    'has_archive'           => true,        
    'exclude_from_search'   => false,
    'publicly_queryable'    => true,
    'rewrite'               => $rewrite,
      'capability_type'       => 'post',
    );

    register_post_type( 'venue_post', $args );
}

function venue_locationCategories() {
  $rewrite = array(
    'slug'                       => 'venue-location',
    'with_front'                 => true,
    'hierarchical'               => false,
  );
  $args = array(
    'labels'                     => $labels,
    'hierarchical'               => true,
    'public'                     => true,
    'show_ui'                    => true,
    'show_admin_column'          => true,
    'show_in_nav_menus'          => true,
    'show_tagcloud'              => true,
    'rewrite'                    => $rewrite,
   );
 }
   register_taxonomy( 'locationCategories', array( 'venue_post' ), $args );

然后我设置了一个名为以下内​​容的模板页面:

taxonomy-locationCategories.php

但是当我访问分类标准页面时,例如www.example.com/locationcategories/london 我只是得到了404.任何想法我都缺少了我已经刷新永久链接。

1 个答案:

答案 0 :(得分:1)

您使用重写规则,允许您从分类名称更改分类标准。

您的分类是locationCategories,您的分类标签是场地管理。

存档页面

www.example.com/venue-loaction/

自定义帖子类型页面

www.example.com/venue-loaction/london
相关问题