Custom taxonomy not created, same code works fine in functions.php

[ad_1]

I have successfully added other PHP snippets, but the following code is not creating the ‘Brand’ taxonomy:

add_action( 'init', 'my_brands_register_taxonomy', 0 );
function my_brands_register_taxonomy() {
$labels = array(
'name' => _x( 'Brand', 'taxonomy general name', 'deliboutique' ),
'singular_name' => _x( 'Brand', 'taxonomy singular name', 'deliboutique' ),
'search_items' => __( 'Search Brands', 'deliboutique' ),
'popular_items' => __( 'Popular Brands', 'deliboutique' ),
'all_items' => __( 'All Brands', 'deliboutique' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Edit Brand', 'deliboutique' ),
'update_item' => __( 'Update Brand', 'deliboutique' ),
'add_new_item' => __( 'Add New Brand', 'deliboutique' ),
'new_item_name' => __( 'New Brand Name', 'deliboutique' ),
'separate_items_with_commas' => __( 'Separate Brands with commas', 'deliboutique' ),
'add_or_remove_items' => __( 'Add or remove Brands', 'deliboutique' ),
'choose_from_most_used' => __( 'Choose from the most used Brands', 'deliboutique' ),
'menu_name' => __( 'Brands', 'deliboutique' ),
);
register_taxonomy('brands','product',array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'brand' ),
));
}

The same code dropped into the functions.php file creates the taxonomy.

  • This topic was modified 30 minutes ago by CarolineElisa. Reason: Meant to say taxonomy, not CPT

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer