H::register_taxonomy( $taxonomy, $post_type, [$args] )
$taxonomy (string) - Unique name of the Taxonomy. Example: "brand", "city". Don't use these reserved name.
$taxonomy
$post_type (string) - Where to attach this taxonomy to.
$post_type
$args (array - optional) - Available arguments are:
$args
label (string) - Custom display name in admin panel. Default is $name capitalized.
$name
slug (string) - Base URL for taxonomy page, cannot be the same as existing post type. Default is the same as $name.
IMPORTANT: Every time you add / change taxonomy, visit "Settings > Permalink" in WP Admin to clear the cache.
BASIC
Registering brand taxonomy to product post type:
brand
product
H::register_taxonomy( 'brand', 'product' );
CHANGE LABEL & SLUG
H::register_taxonomy('brand', 'product', [ 'label' => 'The Brand', 'slug' => 'b' ] );
With the snippet above, the admin label will say "The Brand" and the URL for taxonomy page will be /b/brand-name instead of /brand/brand-name.
/b/brand-name
/brand/brand-name
There was an error while loading. Please reload this page.