This question relates to a solution found here from user somatic and mikeSchinkel

I am testing somatic's solution, and it loads and populates the dropdown with no issues, but When you click filter, it does not filter anything. I am on WP version 3.0.4.

My custom post type = "listings" my custom taxonomy = "Locations"

the code:

add_action( 'restrict_manage_posts', 'my_restrict_manage_posts' );
function my_restrict_manage_posts() {

    // only display these taxonomy filters on desired custom post_type listings
    global $typenow;
    if ($typenow == 'listings') {

        // create an array of taxonomy slugs you want to filter by - if you want to retrieve all taxonomies, could use get_taxonomies() to build the list
        $filters = array('Locations');

        foreach ($filters as $tax_slug) {
            // retrieve the taxonomy object
            $tax_obj = get_taxonomy($tax_slug);
            $tax_name = $tax_obj->labels->name;
            // retrieve array of term objects per taxonomy
            $terms = get_terms($tax_slug);

            // output html for taxonomy dropdown filter
            echo "<select name='$tax_slug' id='$tax_slug' class='postform'>";
            echo "<option value=''>Show All $tax_name</option>";
            foreach ($terms as $term) {
                // output each select option line, check against the last $_GET to show the current option selected
                echo '<option value='. $term->slug, $_GET[$tax_slug] == $term->slug ? ' selected="selected"' : '','>' . $term->name .' (' . $term->count .')</option>';
            echo "</select>";

Am I missing something in there to make the filter work? I am organizing my column's with the following code, not what was in step 3 and 4. (not sure if this is the issue?)

add_action("manage_posts_custom_column",  "listing_custom_columns");
add_filter("manage_edit-listings_columns", "listing_edit_columns");

function listing_edit_columns($columns){
  $columns = array(
    "cb" => "<input type=\"checkbox\" />",
    "title" => "Listing Name",
    "address" => "Address",
    "Locations" => "Location",

  return $columns;
function listing_custom_columns($column){
  global $post;

  switch ($column) {
    case "address":
      $custom = get_post_custom();
      echo $custom["address_meta"][0];
    case "Locations":
      echo get_the_term_list($post->ID, 'Locations', '', ', ','');

Any help would be appreciated. thank you.


I had the exact same problem like you. Don't know why mikeSchinkels code doesn't work anymore. But there are a new (WordPress 3.1) code for this, that works.

I found it here: https://gist.github.com/541505#gistcomment-28441 (in mikes comments)

I replaced mikes code from line 65 to 95, with this code. (check Mikes code on github) Other then that, follow his original structure.


I think that in the example you gave, the term that you put in the $filters array has to be lower case since it is a slug. So 'Location' has to be 'location' or whatever the slug is for that taxonomy.

  • I tried putting 'locations' in instead of 'Locations' and it then wouldnt give me the list form the taxonomy. Thanks for the suggestion though. Jan 10 '11 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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