Adding tag automatically on post save
-
Hello!
Could you please help me on my issue!
I am using edd front end submission If the vendor submits a new download I want to add automatically some tags.
Adding category is working perfectly but adding tags not working but the function works once when I click the update button in the admin area.
Do you guys have any idea I am a valued customer of edd, please?
This is My code:
<?php
add_action(‘save_post’,’add_tags_on_postsave’);
function add_tags_on_postsave($post_id){
global $post;
if ( get_post_type($post_id) != ‘download’){
return;
}//adding a category works perfectly.
$categ = array( 10 );
wp_set_post_terms( $post_id, $categ, ‘download_category’ , true );//adding tags not working but in the admin area when I click the update button.
wp_set_post_terms( $post_id, ‘Tag1,tag2,tag3’, ‘download_tag’, true );
}
?>
- The topic ‘Adding tag automatically on post save’ is closed to new replies.