Skip to content

Instantly share code, notes, and snippets.

@interactiveRob
Last active March 31, 2021 13:56
Show Gist options
  • Select an option

  • Save interactiveRob/f6742c36f226044dc5c0094d18b35c31 to your computer and use it in GitHub Desktop.

Select an option

Save interactiveRob/f6742c36f226044dc5c0094d18b35c31 to your computer and use it in GitHub Desktop.
Wordpress register custom taxonomy
<?php
add_action( 'init', 'steam_register_custom_taxonomy_effect');
/**
* Register Custom Taxonomy
*
* @return void
*/
function steam_register_custom_taxonomy_effect()
{
$labels = array(
'name' => _x( 'Effects', 'Taxonomy General Name'),
'singular_name' => _x( 'effect', 'Taxonomy Singular Name'),
'menu_name' => __( 'Effects'),
'all_items' => __( 'All Effects'),
'parent_item' => __( 'Parent effect'),
'parent_item_colon' => __( 'Parent effect:'),
'new_item_name' => __( 'New effect Name'),
'add_new_item' => __( 'Add New effect'),
'edit_item' => __( 'Edit effect'),
'update_item' => __( 'Update effect'),
'separate_items_with_commas'=> __( 'Separate effects with commas'),
'search_items' => __( 'Search effects'),
'add_or_remove_items' => __( 'Add or remove effects'),
'choose_from_most_used' => __( 'Choose from the most used effects'),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'public' => false,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'rewrite' => array( 'slug' => 'product-effects', 'with_front' => false ),
);
register_taxonomy( 'effect', ['product'], $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment