Support » Fixing WordPress » Get tag slug

  • Is there a way I can retrieve a tag slug from a tag title?

    I need to use the tag slug to retrieve the query post because it does not accept the tag title. Can anyone help with getting the tag slug?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Anyone at all?

    I’ve been fighting with the same problem. I did come up with a solution, but it’s slightly ugly: check the db. Here’s a function I wrote to do the trick:

    function mikko_get_tag_slug($title) {
    	global $wpdb;
    	$slug = $wpdb->get_var("SELECT slug FROM $wpdb->terms WHERE name='$title'");
    	return $slug;

    Then I just

    $slug = mikko_get_tag_slug(single_tag_title('', false));
    query_posts('tag=' . $slug); ?>

    in the template code.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get tag slug’ is closed to new replies.