I have noticed my custom taxonomy filters no longer work in the 3.3.1 admin as per these methods:
Adding a Taxonomy Filter to Admin List for a Custom Post Type?
I also discovered that to filter a taxonomy the query string requires both the &taxonomy=whatever
and &term=something
to be passed. Anyone have any experience in this, and solutions to offer?
Here’s some code from the question as an example:
add_action('restrict_manage_posts','restrict_listings_by_business');
function restrict_listings_by_business() {
global $typenow;
global $wp_query;
if ($typenow=='listing') {
$taxonomy = 'business';
$business_taxonomy = get_taxonomy($taxonomy);
wp_dropdown_categories(array(
'show_option_all' => __("Show All {$business_taxonomy->label}"),
'taxonomy' => $taxonomy,
'name' => 'business',
'orderby' => 'name',
'selected' => $wp_query->query['term'],
'hierarchical' => true,
'depth' => 3,
'show_count' => true, // Show # listings in parens
'hide_empty' => true, // Don't show businesses w/o listings
));
}
}
and
add_filter('parse_query','convert_business_id_to_taxonomy_term_in_query');
function convert_business_id_to_taxonomy_term_in_query($query) {
global $pagenow;
$qv = &$query->query_vars;
if ($pagenow=='edit.php' &&
isset($qv['taxonomy']) && $qv['taxonomy']=='business' &&
isset($qv['term']) && is_numeric($qv['term'])) {
$term = get_term_by('id',$qv['term'],'business');
$qv['term'] = $term->slug;
}
}
There are couple of things wrong with your code…
term
that gives the ID of the term, butbusiness
(in this case), since this is the name you’ve provided for the drop-down menu. Replace all instances ofterm
withbusiness
parse_query
function.The following worked for me (except I changed ‘listing’ to ‘post’)…