$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>categories - Why custom taxomony not showing when create a post?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

categories - Why custom taxomony not showing when create a post?

matteradmin9PV0评论

I have created taxomony which are showing in wordpress Menubar in Post tab. But when i create a new post or edit my post it is not showing with categories. Can any one help me out that where i am wrong.

Functions.php

add_action( 'init', 'register_taxonomy_Emerates_State' );

function register_taxonomy_Emerates_State() {
    $labels = array( 
    'name' => _x( 'Emerates_State', 'State' ),
    'singular_name' => _x( 'Emerates_State', 'State' ),
    'search_items' => _x( 'Search Emerates_State', 'State' ),
    'popular_items' => _x( 'Popular Emerates_State', 'State' ),
    'all_items' => _x( 'All Emerates_State', 'State' ),
    'parent_item' => _x( 'Parent Emerates_State', 'State' ),
    'parent_item_colon' => _x( 'Parent Emerates_State:', 'State' ),
    'edit_item' => _x( 'Edit Emerates_State', 'State' ),
    'update_item' => _x( 'Update Emerates_State', 'State' ),
    'add_new_item' => _x( 'Add New Emerates_State', 'State' ),
    'new_item_name' => _x( 'New Emerates_State', 'State' ),
    'separate_items_with_commas' => _x( 'Separate Emerates_State with commas', 'State' ),
    'add_or_remove_items' => _x( 'Add or remove Emerates_State', 'State' ),
    'choose_from_most_used' => _x( 'Choose from the most used Emerates_State', 'State' ),
    'menu_name' => _x( 'Emerates_State', 'State' ),
);

$args = array( 
    'labels' => $labels,
    'public' => true,
    'show_in_nav_menus' => true,
    'show_ui' => true,
    'show_tagcloud' => false,
    'show_admin_column' => true,
    'hierarchical' => true,
    'with_front'=> true,
    'query_var' => true,
    'has_archive' => true,
    'rewrite' => array( 'slug' => 'state' )
);

register_taxonomy( 'State', array('post'), $args );
}

See Images:

I have created taxomony which are showing in wordpress Menubar in Post tab. But when i create a new post or edit my post it is not showing with categories. Can any one help me out that where i am wrong.

Functions.php

add_action( 'init', 'register_taxonomy_Emerates_State' );

function register_taxonomy_Emerates_State() {
    $labels = array( 
    'name' => _x( 'Emerates_State', 'State' ),
    'singular_name' => _x( 'Emerates_State', 'State' ),
    'search_items' => _x( 'Search Emerates_State', 'State' ),
    'popular_items' => _x( 'Popular Emerates_State', 'State' ),
    'all_items' => _x( 'All Emerates_State', 'State' ),
    'parent_item' => _x( 'Parent Emerates_State', 'State' ),
    'parent_item_colon' => _x( 'Parent Emerates_State:', 'State' ),
    'edit_item' => _x( 'Edit Emerates_State', 'State' ),
    'update_item' => _x( 'Update Emerates_State', 'State' ),
    'add_new_item' => _x( 'Add New Emerates_State', 'State' ),
    'new_item_name' => _x( 'New Emerates_State', 'State' ),
    'separate_items_with_commas' => _x( 'Separate Emerates_State with commas', 'State' ),
    'add_or_remove_items' => _x( 'Add or remove Emerates_State', 'State' ),
    'choose_from_most_used' => _x( 'Choose from the most used Emerates_State', 'State' ),
    'menu_name' => _x( 'Emerates_State', 'State' ),
);

$args = array( 
    'labels' => $labels,
    'public' => true,
    'show_in_nav_menus' => true,
    'show_ui' => true,
    'show_tagcloud' => false,
    'show_admin_column' => true,
    'hierarchical' => true,
    'with_front'=> true,
    'query_var' => true,
    'has_archive' => true,
    'rewrite' => array( 'slug' => 'state' )
);

register_taxonomy( 'State', array('post'), $args );
}

See Images:

Share Improve this question asked Mar 17, 2019 at 10:12 Jamal AhmadJamal Ahmad 1032 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

It looks like you're using the new Block Editor (Gutenberg).

In such case, you should know that this editor is based on REST. So if you want to see your custom taxonomy in this editor, you have to make it visible in rest.

You should set show_in_rest parameter to true.

$args = array( 
    'labels' => $labels,
    'public' => true,
    'show_in_nav_menus' => true,
    'show_ui' => true,
    'show_tagcloud' => false,
    'show_admin_column' => true,
    'hierarchical' => true,
    'with_front'=> true,
    'query_var' => true,
    'has_archive' => true,
    'rewrite' => array( 'slug' => 'state' ),
    'show_in_rest' => true
);
Post a comment

comment list (0)

  1. No comments so far