In the following code I can set tags automatically and add to a pre-existing category:

<?php function update_post_terms( $post_id ) {
    if ( $parent = wp_is_post_revision( $post_id ) )
        $post_id = $parent;
    $post = get_post( $post_id );
    if ( $post->post_type != 'post' )

    wp_set_post_terms( $post_id, 'News from, Videos from, Books from', 'post_tag', true );

    wp_set_post_categories( $post_id );
add_action( 'wp_insert_post', 'update_post_terms' ); ?>

What I'm trying to do is take 3 tags that will be created automatically, and merge with the category added to the post.

For example: News from, Videos from, Books from (3 predefined tags).

If I create the Technology category, when publishing the tags would be created: News from Technology, Videos from Technology, Books from Technology.

  • 1
    How do you connect the post to the Technology category? If every post in category X also has 3 tags of Something from X what's the point of the tags? – Tom J Nowell Oct 25 '19 at 21:07
  • This is just an example. It could be used, for example, on a quote site. If I create a category with the writer's name, automatic tags would be created such as: Quotes from Thomas Jefferson, Biography from Thomas Jefferson, Works from Thomas Jefferson. – BobGCA Oct 25 '19 at 21:29

Try to use this plugin https://wordpress.org/plugins/bulk-edit-categories-tags/

Best regards

  • The plugin has many functions, but not exactly what I'm looking for. And most functions are premium and cost $59.99. – BobGCA Oct 26 '19 at 17:06

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.