Get Post Tags in Dropdown
-
I have a function that displays the current posts tags in a dropdown that opens the category page onselect. However, I thought the code would also work for tags, but for some reason it does not. Here is the category dropdown code.
function drop_cats() { echo "<select onChange=\"document.location.href=this.options[this.selectedIndex].value;\">"; echo "<option>Categories</option>\n"; foreach (get_the_category() as $cat) { echo "<option value=\""; echo get_category_link($cat->cat_ID); echo "\">".$cat->cat_name."</option>\n"; } echo "</select>"; }
Here is my attempt at the tags one, but no go.
function drop_tags() { echo "<select onChange=\"document.location.href=this.options[this.selectedIndex].value;\">"; echo "<option>Tags</option>\n"; foreach (get_the_tags() as $tag) { echo "<option value=\""; echo get_tag_link($tag->tag_ID); echo "\">".$cat->cat_name."</option>\n"; } echo "</select>"; }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Get Post Tags in Dropdown’ is closed to new replies.