Empty searchstring'; elseif ($_POST['tagname_like'] != '' && $_POST['tagname_is'] != '') $error = 'Only one field should be used for the search'; # How to look in the column $search = (empty($_POST['tagname_like'])) ? ' = \''.$wpdb->escape($_POST['tagname_is']).'\'' : ' LIKE \'%'.$wpdb->escape($_POST['tagname_like']).'%\''; if (trim($error) == '') $tags = $wpdb->get_results( "SELECT terms.name, terms.slug, taxonomy.count FROM $wpdb->terms AS terms INNER JOIN $wpdb->term_taxonomy AS taxonomy ON terms.term_id = taxonomy.term_id WHERE taxonomy.taxonomy = 'post_tag' AND terms.name {$search} AND taxonomy.count <> 0 ORDER BY ".$_POST['order_by'].' '.$_POST['tag_sort'], OBJECT); } # Default form $str .= '

Search tag name

Tag name like '.$error.'
OR
Tag name is '.$error.'

Result

Show how many times used
Order by
Sort ASC DESC
'; # If the submit button is hit if (@isset($tags)){ # Show results (count) $str .= ''. count($tags) .' tags found'; # Ordered list (numbered) $str .= '
    '; foreach ($tags as $tag){ # Get the current itterated term object $term_obj = @get_term_by('slug', $tag->slug, 'post_tag', OBJECT); # If the count checkbox has been set - show usage count $show_count = (@isset($_POST['count_times'])) ? '('.$tag->count.')' : ''; # The list item $str .= '
  1. '.strtolower($tag->name).' '.$show_count.'
  2. '; } $str .= '
'; } # Return the page return $str; } # Add shortcode | used in page add_shortcode('tagsarchive', 'os_TagsArchive'); ?>