简体   繁体   中英

Custom Post Type Category subpage

Okay, so I have created a new custom post type, named sectors, and a sub category for this, named categories.

后端

    add_action( 'init', 'create_sector_cat' );

function create_sector_cat() {
    register_taxonomy(
        'SectorCategories',
        'sectors',
        array(
            'label' => __( 'Sector Categories' ),
            'rewrite' => array( 'slug' => 'sectorcategories' ),
            'hierarchical' => true,
        )
    );
}

Now, when I press sector categories, it shows all categories which are created, using a file named sectorcategories.php

I then will have different 'products' inside this category, and I understand the filename should be taxonomy-sectorcategories.php, but this file isnt working?

The first parameter is the taxonomy name. and according to the Wordpress codex it should only contain lowercase letters and the underscore character. Read more

I see you have a capital letter in your taxonomy name and that might be the problem. I could be wrong but I have run into trouble with this as well, i think it is very case sensitive.

ps: I know this answer comes late but it if it works it might still help someone else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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