custom browse by

In your tag code you are missing a few quotes chars, the $tag var, and you cant endforeach like that i add braces for it:

<div class="tag-cloud" style="margin: 20px 0;">
        <?php
        echo '<select class="tags">';
        // Add custom option as default
        echo '<option>' . __('Select Tag', 'text-domain') . '</option>';
        // Get categories as array
        $tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
        foreach ((array) $tags as $tag){
        // Check if current term ID is equal to term ID stored in database
            $selected = ($tag == $tag->term_id ) ? 'selected' : '';
        echo '<option value="<a href="' . get_tag_link ($tag->term_id) . '" rel = "tag">' . $tag->name . '(' . $tag->count . ')'.'</option>';
        }
        echo '</select>';
        ?>                  
    </div>