0

I see this post https://wordpress.stackexchange.com/a/14405/144156

Code it working, but i want change category = my custom taxonomy "chuyen-muc", someone help me, thanks.

  • See the docs for wp_dropdown_categories() function, you can add a paramater there to use your taxonomy. Is that it? – Leo Germani May 23 '18 at 19:55
  • @LeoGermani yeah i think so, im add: wp_dropdown_categories( array('taxonomy' => 'my_custom_taxonomy' 'name' => 'category_id[]', 'hide_empty' => false, 'echo' => false, ) ); But click Continue it not working, not choose my custom taxonomy. – Duy Hữu May 23 '18 at 20:36
0

Use the 'save_post' hook to programmatically enteract with your new post when it is created, then use the wp_set_post_terms() function to assign your term,

add_action('save_post','set_post_default_category', 10,3);
function set_post_default_category($post_id, $post, $update){
  if($update) return; //only want to set if this is a new post!
  if('post' !== $post->post_type) return;  //only set for post_type = post!
  $term = get_term_by('slug', 'my-custom-term', 'category');//get the default term using the slug, its more portable!
  wp_set_post_terms( $post_id, $term->term_id, 'category', true );
}
  • thanks, but i just want know how change code in link, from "choose category" to "choose my custom category" before creating new post! – Duy Hữu May 23 '18 at 19:22
  • you want to change the label in the editor page? – Aurovrata May 24 '18 at 5:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.