简体   繁体   English

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

[英]Wordpress custom post type category listings not showing up

I have set up a custom post type called 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 );
}

The products work with my custom archive page . 这些产品可与我的自定义存档页面一起使用 But not with the categories; 但是没有类别; I just get a "not found". 我只是得到一个“未找到”。

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

I have deleted .htaccess and resaved the permalinks.. (/%postname%/) 我已删除.htaccess并重新保存了永久链接..(/%postname%/)

Any ideas as to why this is happening? 有什么想法为什么会这样?

Use for custom taxonomy category list plugin for display category sidebar. 用于显示类别侧栏的自定义分类类别列表插件。 or 要么

You can use the wp_list_categories function to create a list in your sidebar, the Codex article has a code example, but something like this should work: 您可以使用wp_list_categories函数在边栏中创建列表, Codex文章提供了一个代码示例,但是类似的事情应该可以解决:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM