I am looking for a way to auto tag custom posts in Wordpress without using a plugin.
I have a custom post type 'tech-video' and I want to auto tag it with the video tag every time a post gets published of that type.
I tried this code snippet but it doesn't work:
/* Auto Tag Tech Videos */
add_action('publish_tech_video', 'tag_tech_video', 10, 2);
function tag_tech_video($post_id, $post){
wp_set_post_terms( $post_id, 'tech-video', 'video', true );
}
I'm not skilled with either PHP or Wordpress hooks so any help is appreciated.
Thank you,