Custom Taxonomy Filter not working in Admin edit.php 3.1(b2)
-
The filter function I have been using in 3.0.3 seems to be now broken in 3.1 beta 2.
I know that filtering by multiple taxonomies is going to be part of 3.1, but I haven’t yet found anything relating to this new feature set. I also was not sure if the following method is now replaced by something because of the ability to do multiple queries.The following code, instead of successfully filtering the posts as before, somehow manages to even return other post types!
If this turns out not to be related to a bug, I’ll be happy to repost in another forum instead.
“Cruise” is the custom post type and “destination” is the custom taxonomy.
add_action('restrict_manage_posts','restrict_cruises_by_destinations'); function restrict_cruises_by_destinations() { global $typenow; global $wp_query; if ($typenow=='cruise') { $taxonomy = 'destination'; $destination_taxonomy = get_taxonomy($taxonomy); wp_dropdown_categories(array( 'show_option_all' => __("Show All {$destination_taxonomy->label}"), 'taxonomy' => $taxonomy, 'name' => 'destination', 'orderby' => 'name', 'selected' => $wp_query->query['term'], 'hierarchical' => true, 'child_of' => 0, 'depth' => 3, 'show_count' => true, 'hide_empty' => true, )); } } add_filter('parse_query','convert_destination_id_to_taxonomy_term_in_query'); function convert_destination_id_to_taxonomy_term_in_query($query) { global $pagenow; $qv = &$query->query_vars; if( $pagenow=='edit.php' && isset($qv['taxonomy']) && $qv['taxonomy']=='destination' && isset($qv['term']) && is_numeric($qv['term']) ) { $term = get_term_by('id',$qv['term'],'destination'); $qv['term'] = $term->slug; } }
Any help would be much appreciated.
Happy Holidays to all!
- The topic ‘Custom Taxonomy Filter not working in Admin edit.php 3.1(b2)’ is closed to new replies.