Not working anymore since WP 5.5
The plugin worked fine in June with WP 5.4.2.
But now with WP 5.5.1 the post search is broken, so that no result are shown. Also the select box "All Schlagwörter" ("All tags") is empty ... and causes the browser to freeze a few seconds, when I try to open the select box.
Can you reproduce it with WP 5.5.x and can / will you provide a fix?
Otherwise I have to find another plugin / solution. :(
Thanks!
@unitb-ore did you find a solution for this problem?
No, I disabled this plugin (and have no other solution yet). :-(
@unitb-ore I found a solution. Add this code to your functions.php:
function product_attribute_sorting_dropdown() {
global $typenow;
$taxonomy = 'pa_brand';
if ( $typenow == 'product' ) {
$selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : '';
$info_taxonomy = get_taxonomy($taxonomy);
wp_dropdown_categories(array(
'show_option_all' => __("{$info_taxonomy->labels->name}"),
'taxonomy' => $taxonomy,
'name' => $taxonomy,
'orderby' => 'name',
'selected' => $selected,
'show_count' => true,
'hide_empty' => true,
));
};
}
add_action('parse_query', 'product_attribute_sorting_query');
function product_attribute_sorting_query( $query ) {
global $pagenow;
$taxonomy = 'pa_brand';
$q_vars = &$query->query_vars;
if ( $pagenow == 'edit.php' && isset($q_vars['post_type']) && $q_vars['post_type'] == 'product' && isset($_GET[$taxonomy]) && is_numeric($_GET[$taxonomy]) && $_GET[$taxonomy] != 0) {
$tax_query = (array) $query->get('tax_query');
$term = get_term_by('id', $_GET[$taxonomy], $taxonomy);
$tax_query[] = array(
'taxonomy' => $taxonomy,
'field' => 'slug',
'terms' => array($term->slug),
'operator' => 'AND'
);
$query->set( 'tax_query', $tax_query );
}
I used it for the custom pa_brand taxonomy. Guess you can give this a try?
Thx!
How do you use "product_attribute_sorting_dropdown"?
@unitb-ore I don't understand your question :). What do you want to know exactly?
How can I integrate a select box for the taxonomy into the page "/wp-admin/edit.php"? When I call your function "product_attribute_sorting_dropdown" and rewrite the code for "post_tag", then a select box appears on this page showing all tags -- fine. But it is in the upper left corner and it is ignored for the search when clicking on "Filter" (button).
function product_attribute_sorting_dropdown() {
global $pagenow;
$paramName = 'taxonomy';
if ($pagenow == 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] == 'post') {
$selected = isset($_GET[$paramName]) ? $_GET[$paramName] : '';
$info_taxonomy = get_taxonomy('post_tag');
wp_dropdown_categories(array(
'show_option_all' => __("{$info_taxonomy->labels->name}"),
'taxonomy' => 'post_tag',
'name' => $paramName,
'orderby' => 'name',
'selected' => $selected,
'show_count' => true,
'hide_empty' => true,
));
}
}
Did you add the complete code? I have it integraded as a normal dropdown box:

Okay, I found a solution: https://wordpress.stackexchange.com/questions/578/adding-a-taxonomy-filter-to-admin-list-for-a-custom-post-type
Now it works! :)
Here is my complete solution:
add_action('parse_query', 'filter_posts_by_tag');
function filter_posts_by_tag($query) {
global $pagenow;
$paramName = 'taxonomy';
$q_vars = &$query->query_vars;
$isPostsPage = ($pagenow == 'edit.php') && isset($q_vars['post_type']) && ($q_vars['post_type'] == 'post');
$hasTagParam = isset($q_vars[$paramName]) && is_numeric($q_vars[$paramName]) && ($q_vars[$paramName] != 0);
if ($isPostsPage && $hasTagParam) {
$tax_query = (array) $query->get('tax_query');
$term = get_term_by('id', $_GET[$paramName], 'post_tag');
if ($term) {
$tax_query[] = array(
'taxonomy' => 'post_tag',
'field' => 'slug',
'terms' => array($term->slug),
'operator' => 'AND'
);
$query->set('tax_query', $tax_query);
}
}
}
add_action('restrict_manage_posts', 'add_tag_filter_to_posts_admin_page');
function add_tag_filter_to_posts_admin_page() {
global $typenow;
global $wp_query;
if ($typenow == 'post') {
$paramName = 'taxonomy';
$query = &$wp_query->query;
$selected = isset($query[$paramName]) ? $query[$paramName] : '';
$info_taxonomy = get_taxonomy('post_tag');
wp_dropdown_categories(array(
'show_option_all' => __("Alle {$info_taxonomy->labels->name}"),
'taxonomy' => 'post_tag',
'name' => $paramName,
'orderby' => 'name',
'selected' => $selected,
'hierarchical' => false,
'show_count' => true, // Show # posts
'hide_empty' => true, // Don't show tags w/o posts
));
}
}
I do not understand, why it does not work, when I change "$paramName" to a different value (then the selected value is not set in the select box). But with this $paramName it works. 👍