Moved to: WoodyHayday.com
Woody Hayday

Fresh Ideas

Hi there! This is my old blog, I don't hang around here much.
You can now find me trying to mix things up here:
Visit WoodyHayday.com Subscribe To My Email List

get_tag_name function for wordpress

get_cat_name is a simple useful function to get the category name from its id in wordpress, there isn’t one for tag (and you cant use the same one…) so here’s I adapted it for tags. TBH its super lazy to be using this, but meh. Uses get_term.

function get_tag_name( $tag_id ) {

     $tag_id = (int) $tag_id;
     $tag = get_term( $tag_id, 'post_tag'; );

     if ( ! $tag || is_wp_error( $tag ) )

          return '';

     return $tag->name;

}

I am writing Automated Editor, a wordpress plugin which will give you a bunch of pro automation possibilities, in case you were wondering.

This entry was posted in PHP, Snippets, Wordpress. Bookmark the permalink. Both comments and trackbacks are currently closed.

One Comment

  1. Naveed Abbas
    Posted April 26, 2012 at 10:04 pm

    Hi
    thanks for the function that function really helped me alot

Woody Hayday

Comments Archive

Hi there. This is my old blog and it's archived, so you can no longer post new comments on this post (get_tag_name function for wordpress).

Read my new blog about writing software and stories at WoodyHayday.com

The New Blog
WoodyHayday.com
A Quote..
"Give me the fruitful error any time, full of seeds, bursting with its own corrections. You can keep your sterile truth for yourself."
Vilfredo Pareto
Old Random Projects
    © Woody Hayday 2008-2017