I have the following code but obliviously it doesn't work as expected. It should take the terms from the taxonomy TAXONOMY_NAME only for custom post type CUSTOM_POST_TYPE and add as tags.

add_action('save_post','add_tags_auto');
function add_tags_auto($id) {

    $terms = get_the_terms( $post->id, 'TAXONOMY_NAME' ); // get an array of all the terms as objects.
    $add_tags = array();

    foreach( $terms as $term ) {
        $add_tags[] = $term->slug; // save the slugs in an array
    }
    $temp = array();
    $tags = get_the_tags($id);
    foreach ($tags as $tag)
        $temp[] = $tag->name;
    $tags = $temp;

    $post = get_post($id);

    if ($post->post_type != 'CUSTOM_POST_TYPE')
        return false;

    foreach ($add_tags as $t)
        if (!in_array($t,$tags))
            wp_add_post_tags($id,$add_tags);
}
link|improve this question
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.