dousuo8400 2017-11-10 12:59
浏览 183
已采纳

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

I have created a custom post and a custom taxonomy for that post and both the post type and the taxonomy work fine:

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 );

I have then setup a template page named the following:

taxonomy-locationCategories.php

but when I visit the taxonomy page e.g. www.example.com/locationcategories/london I just get a 404. Any idea what I'm missing I have refreshed permalinks.

  • 写回答

1条回答 默认 最新

  • dtgr3392 2017-11-10 13:25
    关注

    You using rewrite rule which allows you to change taxonomy slug from taxonomy name.

    Your taxonomy is locationCategories and your taxonomy slug is venue-loaction.

    Archive page

    www.example.com/venue-loaction/
    

    Custom Post Type page

    www.example.com/venue-loaction/london
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动