Wordpress自定义帖子类型类别列表未显示

时间:2014-02-13 10:16:01

标签: php wordpress .htaccess custom-post-type

我已经设置了一个名为products的自定义帖子类型:

add_action( 'init', 'register_cpt_product' );

function register_cpt_product() 
{
    $labels = array(
        'name' => _x( 'products', 'products' ),
        'singular_name' => _x( 'product', 'products' ),
        'add_new' => _x( 'Add New', 'products' ),
        'add_new_item' => _x( 'Add New product', 'products' ),
        'edit_item' => _x( 'Edit product', 'products' ),
        'new_item' => _x( 'New product', 'products' ),
        'view_item' => _x( 'View product', 'products' ),
        'search_items' => _x( 'Search products', 'products' ),
        'not_found' => _x( 'No products found', 'products' ),
        'not_found_in_trash' => _x( 'No products found in Trash', 'products' ),
        'parent_item_colon' => _x( 'Parent product:', 'products' ),
        'menu_name' => _x( 'products', 'products' ),
    );
    $args = array(
        'labels' => $labels,
        'hierarchical' => false,
        'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ),
        'taxonomies' => array( 'category', 'post_tag' ),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => true,
        'capability_type' => 'post'
    );

    register_post_type( 'products', $args );
}

产品与my custom archive page一起使用。但不是类别;我只是得到了“未找到”。

http://drysuits.dannycheeseman.me/category/lights/

我删除了.htaccess并重新保存了固定链接..(/%postname%/)

有关为何发生这种情况的任何想法?

1 个答案:

答案 0 :(得分:1)

用于显示类别侧边栏的自定义分类法类别列表插件。或

您可以使用wp_list_categories功能在侧边栏中创建一个列表,the Codex article有一个代码示例,但这样的内容应该有效:

<ul>
<?php wp_list_categories('taxonomy=products'); ?>
</ul>