Last active
June 24, 2021 15:40
-
-
Save atwellpub/0b3545423511e50588606654f43edfc9 to your computer and use it in GitHub Desktop.
taxonomy registration for CPT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Example\Register\Taxonomy; | |
class Profile_Tag { | |
static $taxonomy_name; | |
/** | |
* Initialize Profile_Tag class | |
*/ | |
function __construct() { | |
self::$taxonomy_name = 'profile-tag'; | |
self::register_hooks(); | |
} | |
/** | |
* Load action hooks & filters | |
*/ | |
private function register_hooks() { | |
add_action( 'example/routine/register/taxonomies', array(__CLASS__, 'register_taxonomy' )); | |
} | |
/** | |
* Register Taxonomy | |
*/ | |
public static function register_taxonomy() { | |
/* Register Profile Tags Taxonomy */ | |
$labels = array( | |
'name' => __( 'Tags', 'example' ), | |
'singular_name' => __( 'Profile Tag', 'example' ), | |
'search_items' => __( 'Search Profile Tags' , 'example' ), | |
'popular_items' => __( 'Popular Profile Tags' , 'example'), | |
'all_items' => __( 'All Profile Tags' , 'example' ), | |
'parent_item' => null, | |
'parent_item_colon' => null, | |
'edit_item' => __( 'Edit Profile Tag' , 'example' ), | |
'update_item' => __( 'Update Profile Tag' , 'example' ), | |
'add_new_item' => __( 'Add New Profile Tag' , 'example' ), | |
'new_item_name' => __( 'New Profile Tag' , 'example' ), | |
'separate_items_with_commas'=> __( 'Separate Profile Tags with commas' , 'example' ), | |
'add_or_remove_items' => __( 'Add or remove Profile Tags' , 'example'), | |
'choose_from_most_used' => __( 'Choose from the most used profile tags', 'example' ), | |
'not_found' => __( 'No profile tags found.' , 'example'), | |
'menu_name' => __( '+Tags', 'example' ), | |
); | |
$args = array( | |
'hierarchical' => false, | |
'labels' => $labels, | |
'show_ui' => true, | |
'show_admin_column' => true, | |
'show_in_menus' => false, | |
'show_in_nav_menus' => false, | |
'update_count_callback' => '_update_post_term_count', | |
'query_var' => true, | |
'rewrite' => false | |
); | |
register_taxonomy( self::$taxonomy_name , 'example-profile', $args ); | |
} | |
} | |
new Profile_Tag; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment