QuestionsNeed help for creating custom taxonomy
alexanderbiscajin asked 1 year ago

I am creating a custom taxonomy using the code in functions.php but it’s not working properly. Can anyone help me i don’t know where i am doing mistake. I have found this code on https://www.wpblog.com/create-custom-taxonomies-in-wordpress/1 and i don’t know whether the code is not working or might be i am doing something wrong.

//create a custom taxonomy name
function create_cw_hierarchical_taxonomy() {
$labels = array(
‘name’ => _x( ‘Topics’, ‘taxonomy general name’ ),
‘singular_name’ => _x( ‘Topic’, ‘taxonomy singular name’ ),
‘search_items’ => __( ‘Search Topics’ ),
‘all_items’ => __( ‘All Topics’ ),
‘parent_item’ => __( ‘Parent Topic’ ),
‘parent_item_colon’ => __( ‘Parent Topic:’ ),
‘edit_item’ => __( ‘Edit Topic’ ),
‘update_item’ => __( ‘Update Topic’ ),
‘add_new_item’ => __( ‘Add New Topic’ ),
‘new_item_name’ => __( ‘New Topic Name’ ),
‘menu_name’ => __( ‘Topics’ ),
);
// taxonomy register
register_taxonomy(‘topics’,array(‘post’), array(
‘hierarchical’ => true,
‘labels’ => $labels,
‘show_ui’ => true,
‘show_admin_column’ => true,
‘query_var’ => true,
‘rewrite’ => array( ‘slug’ => ‘topic’ ),
));
}

1 Answers
Stratos Karavarakis answered 1 year ago

Before the //create a custom taxonomy name you have forgoten a line. It is the add_action command so wordpress doesn't know where to hook the create_cw_hierarchical_taxonomy.

Check again the website you took the code and you will see it.

Your Answer
4 + 0 =

Accepted file types: png, jpg, pdf

Add another file