• Resolved noonespecialca

    (@noonespecialca)


    I’ve got a little custom script that lets me specify a tag and WP lists 5 recent posts with that tag. I can put this list wherever I want.. in a post, page or custom page. That’s fine and dandy, but after the list I want to provide a link to the associated tag page.

    get_tag_link() requires the numeric $tag_ID but I only have a string.

    For now I’ve hard coded it like this but there has to be a better way.

    <a href="mysite.com/tag/<?php echo $myTagString; ?>/">link</a>

    I suppose this would probably be better…

    <a href="<?php echo get_tag_link(9999); ?>/<?php echo $myTagString; ?>/">link</a>

    But that might cause problems if $myTagString isn’t URL friendly or if I ever get 9999 tags.

    Better ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to get $tag_id from tag name?’ is closed to new replies.