Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

By default the 'all posts' page contains the following filters

  • by date
  • by category

Is there a way I can add 'by tags' as well ?enter image description here

share|improve this question
    
are you want to replace categories dropdown filter with tags? –  Anjum Sep 4 '13 at 18:23
add comment

1 Answer

User 'restrict_manage_posts' filter to add another filter. Use the following code in functions.php

function kc_add_taxonomy_filters() {
global $typenow;

// an array of all the taxonomyies you want to display. Use the taxonomy name or slug
$my_taxonomies = array(  'post_tag' );
switch($typenow){

    case 'post':

        foreach ($my_taxonomies as $tax_slug) {


                    $tax_obj = get_taxonomy($tax_slug);
                    $tax_name = $tax_obj->labels->name;
                    $terms = get_terms($tax_slug);
                    if(count($terms) > 0) {
                        echo "<select name='$tax_slug' id='$tax_slug' class='postform alignleft actions'>";
                        echo "<option value=''>Show All $tax_name</option>";
                        foreach ($terms as $term) {
                            echo '<option value="', $term->slug,'" ',selected( @$_GET[$tax_slug] == $term->slug , $current = true, $echo = false ) , '>' , $term->name ,' (' , $term->count ,')</option>';
                        }
                        echo "</select>";
                    }

        }


    break;
}
}
add_action( 'restrict_manage_posts', 'kc_add_taxonomy_filters' );
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.