- This topic has 4 replies, 2 voices, and was last updated 6 years, 4 months ago by
Steve.
Viewing 4 reply threads
-
AuthorPosts
-
-
September 12, 2015 at 3:59 pm #4311
Carla ChalmersMemberHello,
I’m trying to insert some terms into a custom taxonomy. I want the terms to be pre-populated for the CPT and the client cannot add terms. I have used the following code to but the terms are not showing up. Any idea of what I’m doing wrong?
add_filter('piklist_taxonomies', 'mhs_add_gender_tax'); function mhs_add_gender_tax($taxonomies) { $taxonomies[] = array( 'post_type' => 'mhs_horses' ,'name' => 'mhs_gender_tax' ,'show_admin_column' => true ,'configuration' => array( 'hierarchical' => true ,'labels' => piklist('taxonomy_labels', 'Gender') ,'hide_meta_box' => false ,'show_ui' => true ,'query_var' => true ,'rewrite' => array( 'slug' => 'gender' ) ) ); return $taxonomies; } function gender_insert_terms () { if ( !term_exists( 'Mare', 'mhs_gender_tax' ) ) { wp_insert_term ( 'Mare', 'mhs_gender_tax', array( 'description' => "Mares", 'slug' => 'mares' ) ); } } add_action( 'init', 'gender_insert_terms'); -
September 12, 2015 at 4:00 pm #4312
Carla ChalmersMemberOh, I will also need to add ‘Stallion’ and ‘Gelding’
-
September 12, 2015 at 11:36 pm #4313
SteveKeymaster@txhorselady– If you increase the priority on init it will work:
add_action('init', 'gender_insert_terms', 99); -
September 13, 2015 at 2:15 am #4315
Carla ChalmersMemberYour awesome Steve, Thank You!!!
-
September 14, 2015 at 4:03 pm #4322
SteveKeymasterAlways happy to help. Closing ticket
-
-
AuthorPosts
Viewing 4 reply threads
- The topic ‘Insert Terms Into Custom Taxonomy’ is closed to new replies.