bbPress

Simple, Fast, Elegant

bbPress support forums » Plugins

Tags drop down.. can it be done?

(2 posts)
  • Started 1 year ago by spencerp
  • Latest reply from ardentfrost
  • This topic is not a support question
  1. The suggestion for this came up on the wp-forums list a while back, but.. nothing was posted on the "How-To" for it..

    I was just wondering, what would be the tags "call" for making this possible? Here's an example of what I'm talking about...

    <li><h2>Browse By</h2>
    <select name="archivemenu" onChange="document.location.href=this.options[this.selectedIndex].value;">
    <option value="">Tags</option>
    <?php tag_heat_map(); ?>
    </select>

    What's the actual "call" for the tags, to have them all be listed there? Thanks in advanced.. ;):)

    spencerp

    Posted 1 year ago #
  2. 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.

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.