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];
break;
case "Locations":
echo get_the_term_list($post->ID, 'Locations', '', ', ','');
break;
}
}
Any help would be appreciated. thank you.
