Created
May 14, 2011 23:42
-
-
Save cfpg/972764 to your computer and use it in GitHub Desktop.
WordPress: Get Tag ID when you only have the Tag name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_tag_id_by_name($tag_name) { | |
global $wpdb; | |
$tag_ID = $wpdb->get_var("SELECT * FROM ".$wpdb->terms." WHERE `name` = '".$tag_name."'"); | |
return $tag_ID; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment