不显示自定义分类

时间:2015-07-15 作者:Packy

我创建了一个自定义分类法,如下所示:

function my_taxonomies_custom() {
      $labels = array(
        \'name\'              => _x( \'Post Categories\', \'taxonomy general name\' ),
        \'singular_name\'     => _x( \'Post Category\', \'taxonomy singular name\' ),
        \'search_items\'      => __( \'Search Post Categories\' ),
        \'all_items\'         => __( \'All Post Categories\' ),
        \'parent_item\'       => __( \'Parent Post Category\' ),
        \'parent_item_colon\' => __( \'Parent Post Category:\' ),
        \'edit_item\'         => __( \'Edit Post Category\' ), 
        \'update_item\'       => __( \'Update Post Category\' ),
        \'add_new_item\'      => __( \'Add New Post Category\' ),
        \'new_item_name\'     => __( \'New Post Category\' ),
        \'menu_name\'         => __( \'Post Categories\' ),
      );
      $args = array(
        \'labels\' => $labels,
        \'hierarchical\' => true,
        \'rewrite\' => array(
            \'slug\' => \'custom_category\',
            \'with_front\' => true,
            \'hierarchical\' => true ,
        ),
      );
      register_taxonomy( \'custom_category\', \'post_type_slug\', $args );  
    }
    add_action( \'init\', \'my_taxonomies_custom\', 0 );
通过名为postcat. 根据我的理解,我现在应该能够URL http://example.com/custom_category/postcat 这将使用category.php page可显示类别中的页面列表。当我转到这个URL时,我得到的只是一个页面,上面写着“找不到。很抱歉,您的请求无法完成。”

1 个回复
最合适的回答,由SO网友:cybmeta 整理而成

category.php 模板文件仅用于核心类别分类。自定义分类法的等效项是taxonomy.php. 看见template hierarchy 了解更多信息。

结束

相关推荐