最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

custom post types - How to set "section categories"?

programmeradmin2浏览0评论

I've made a custom post type "Artwork" with CPT UI. In the settings of my CPT, I enabled access to these taxonomies "Categories" and "Section Categories".

When I view my post list, I not only see a column "Categories", but also a column "Section Category". See screenshot.

But where can I assign a section category? There is no taxonomy for section categories. Do I have to create a custom taxonomy and give it a certain name to make it act as "Section Categories"?

I couldn't find any information online...

EDIT: Here's a screenshot that hopefully explains my problem in a better was.

I've made a custom post type "Artwork" with CPT UI. In the settings of my CPT, I enabled access to these taxonomies "Categories" and "Section Categories".

When I view my post list, I not only see a column "Categories", but also a column "Section Category". See screenshot.

But where can I assign a section category? There is no taxonomy for section categories. Do I have to create a custom taxonomy and give it a certain name to make it act as "Section Categories"?

I couldn't find any information online...

EDIT: Here's a screenshot that hopefully explains my problem in a better was.

Share Improve this question edited Apr 12, 2020 at 13:40 HAL2020 asked Apr 12, 2020 at 8:47 HAL2020HAL2020 398 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

If you would like to add taxonomy other than default, you need to create another one by using register_taxonomy() Because by default, only category and post_tag are created and associated to post.

Add the following code in functions.php

// 'post' is the post type name that you want to associate this new taxonomy to.
function q363839_create_new_tax() {
    $args = array(
    // please refer to the link above and add your settings here according to the need
    );
    register_taxonomy( 'section_category', 'post', $args );
}
add_action( 'init', 'q363839_create_new_tax' );

If in case you are creating taxonomy using plugin in. Make sure you choose the following value to true so that it will appear in your custom post type eg. Artwork Admin Column

Show Admin Column - True

Edited: About the theme interference I suddenly have an idea on how to solve the problem that is being created by the theme. You may try to

  1. search the code for register_taxonomy(), see what is the name of the taxonomies
  2. unregister it by unregister_taxonomy()
  3. create your taxonomy in CPT UI

OR

The best, you contact the theme author because the author for assistance knows it the best and will be the support for you.

Then you could be free from interference of the theme provided that you are sure that after removing the taxonomy from the theme will not break your templates. If it break, then you just go to Screen Options to hide the default taxonomy and use your own one.

发布评论

评论列表(0)

  1. 暂无评论