What I am trying to accomplish is to update a taxonomy term name using its slug rather than the $term_id

Wordpress does this by:

<?php wp_update_term( $term_id, $taxonomy, $args )  ?>

Is it possible to do this via the slug instead?

<?php wp_update_term( get_term_by( 'slug', $value, $taxonomy, $output, $filter ) )  ?>

I've been stuck on this for a while - but no success.

The default taxonomy terms are created by a plugin. I am creating a secondary plugin to change the taxonomy terms created by the 'parent' plugin.

Thanks! Roc.

--- Edit --- Should mention that I am not able to update the term by id because the taxonomy id changes based on when the plugin is activated, and if other tags exists before it can be created.

1 Answer 1


As you hinted in your question, you could use get_term_by() to return an object or array containing the term's id, then use it to update that term. Something like this should work:

$your_term = get_term_by( 'slug', 'your_slug', 'your_taxonomy' );

if ( false !== $your_term ) {
    wp_update_term( $your_term->term_id, 'your_taxonomy', $args );




  • Coolio. Thank you very much BigBagel. I'm kind of very much new to WP, and it seems as if the platform is very flexible with what can be done. Just one quick question, can I place this inside of a function with an 'init' action, or would that be unnecessary?
    – Roc
    Commented Apr 28, 2013 at 15:36
  • Since you're altering the results of another plugin, you'll probably want to use the appropriate action and priority to make sure your code is called after the other plugin's code.
    – BigBagel
    Commented Apr 28, 2013 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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