Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Tags drop down.. can it be done?


ardentfrost
Member

@ardentfrost

get_top_tags($recent, $limit) will return an array of tag objects… each object contains the tag ID, tag (tag all lower case), raw tag (tag how it was typed), and tag count (how many times the tag is used). To get the link to a specific tag, you use get_tag_link(). You’d want to use the get_top_tags function like this: get_top_tags(false, X) where X is the number of tags you want displayed.

You can also pull the tags straight from the database. Here’s the code used in functions.php:

$tags = $bbdb->get_results("SELECT * FROM $bbdb->tags ORDER BY tag_count DESC LIMIT $limit")

I’d take out the limit part if you want all the tags. Then, if you want a drop down menu, you can just do this (this is from my head and untested, so it might not work if copy and pasted):

if(!empty($tags) ) :

echo '<select name="userid" id="userid">';

foreach( $tags as $tag) :

echo "<option value='$tag->raw_tag'>$tag->tag</option>";

endforeach;

echo '</select>';

else:

echo "No tags exist";

endif;

Then you just gotta figure out how to either redirect to the desired page using POST data or something like that. Not exactly sure how I’d go about it.

Skip to toolbar