WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible, to search just for tags?

Not any other taxonomies or post types, just tag titles.

share|improve this question
up vote 5 down vote accepted

Yes its very possible, you just need to create your own search form and processing function form:

<form name="tag-search" method="POST" action="">
  <input type="text" vlaue="" name="tag-q" id="tag-q">
  <input type="submit" name="tag-submit" id="tag-submit" value="Search Tags">


if (isset($_POST['tag-submit']) && $_POST['tag-submit'] == "Search Tags" && isset($_POST['tag-q']) && $_POST['tag-q'] != ""){

    // @todo Sanity check and cleanup $_POST['tag-q'] here.

    $args = array('name__like' => $_POST['tag-q']);
    $tags = get_tags($args);
    $html = '<div class="post_tags_search_r">';
    foreach ($tags as $tag){
        $tag_link = get_tag_link($tag->term_id);

        $html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
        $html .= "{$tag->name}</a>";
    $html .= '</div>';
    echo $html;

No this is something i have used in the past, the only downside to this is that name__like is case-insensitive so you might want to add the strtolower version to the name__like.

share|improve this answer
good hook. But this example in unsafe, we should clean up the [tag-q] to avoid problems – ilovewordpress Mar 28 '11 at 21:57
@Happy i agree 100% – Bainternet Mar 28 '11 at 22:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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