So, I had to take the set_tax_query_field_to_id
actionmake a custom walker and amenduse that with the tax_querywp_dropdown_categories()
after it had been created.
Here is the full Class that I am using to add filters for my custom taxonomies to my various custom post typesfunction, as below -
class FGW_CPT_Taxonomy_Filter{
/**
* The customCustom postextended typeFGW_Cat_Slug_Walker toClass
alter* andOutputs the taxonomies to show filters for
term 'slug' as the value *
of each option, not 'term_id' *(as @varis arraydefault)
*/
privateclass $cptFGW_Cat_Slug_Walker =extends array();Walker_CategoryDropdown{
/**
* ConstructorStart the element output
*
* @param required array $cpt string The$output custom post typePassed andby associatedreference. taxonomiesUsed to show filters for (as "array($cpt =>append array(tax1,additional tax2))")content
*/
@param required publicobject function$category __construct($cptCategory =data array()){object
* @param required int $this->cpt$depth = $cpt;
Depth of category in reference to add_action('restrict_manage_posts',parents. array($this,Default 'render_filter'));0
* @param add_action('parse_tax_query',required array($this, 'set_tax_query_field_to_id'));
$args An array of arguments
}
* @param required
int /**
$id * Render ID of the taxonomycurrent filtercategory
*/
public function render_filterstart_el(){
global $typenow;
&$output, $category, $depth = 0, $types$args = array_keysarray($this->cpt); // Grab the post types that are being edited
if(!in_array($typenow, $types)) // Check to see if the page now is one of the custom post types supplied by the user
$id return= false;0){
$filters$pad = $this->cpt[$typenow]; // Grab all of the taxonomies that shold have a filter
foreachstr_repeat($filters as $tax_slug) :
' ', $depth * 3); $tax_obj = get_taxonomy($tax_slug); // GrabCreate the taxonomy objectpadding (from thebefore taxonomynested slugterms)
$dropdown_args = array( //** OutputGenerate the filter dropdown
'show_option_all' => $tax_obj->labels->all_items,
'taxonomy' => $tax_slug,
'name' => $tax_slug,
'orderby' HTML for =>this option 'name',*/
'selected' => (isset($_GET[$tax_slug]) ?$output.= $_GET[strtolowersprintf($tax_slug)] : null),"\t".
'hierarchical' '<option =>class="%1$s" value="%2$s" true%3$s>%4$s%5$s</option>',
'depth' /** %1$s - 'class' attribute */ =>'level-' . 0$depth,
'show_count'/** %2$s - 'value' attribute */ => false$category->slug,
'hide_empty' => false
);
wp_dropdown_categories($dropdown_args);
endforeach;
}
/**
* Change the 'field' key in all tax_query related settings to 'id'
%3$s - 'selected' attribute */
public function set_tax_query_field_to_id($query){
global $typenow;
if(!isset($query$category->tax_query))
return false;
$types>slug === array_keys($this->cpt$args['selected']); // Grab the post types that are being edited
? ' selected="selected"' : if(!in_array($typenow'', $types)) // Check to see if the page now is one of the custom post types supplied by the user
return false;
$filters/** =%4$s $this->cpt[$typenow]; option text /*/ Grab all of the taxonomies that shold have a filter
foreach($filters as $tax_slug) :
if(isset($query->tax_query->queries)) : foreach($query->tax_query$category->queries as &$single_tax_query) :>name,
/** %5$s - The term count */ if($single_tax_query['taxonomy'] === $tax_slug$args['show_count'])
$single_tax_query['field'] = 'id';
endforeach;
endif;
? if(isset' ($query->tax_query->queried_terms))' :. foreach($query->tax_query$category->queried_terms as $term>count =>. &$settings')' :
''
if($term === $tax_slug)
$settings['field'] = 'id';
endforeach;
endif;
endforeach;;
}
}