Advertisement
advokatb

Untitled

Sep 29th, 2020
1,392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. add_action('parse_query', 'devise_product_attribute_sorting_query_2');
  2. function devise_product_attribute_sorting_query_2( $query ) {
  3.     global $pagenow;
  4.     $taxonomy  = 'pa_design';
  5.     $q_vars    = &$query->query_vars;
  6.     if ( $pagenow == 'edit.php' && isset($q_vars['post_type']) && $q_vars['post_type'] == 'product' && isset($q_vars[$taxonomy]) && is_numeric($q_vars[$taxonomy]) && $q_vars[$taxonomy] != 0 ) {
  7.         $term = get_term_by('id', $q_vars[$taxonomy], $taxonomy);
  8.         $q_vars[$taxonomy] = $term->slug;
  9.     }
  10. }
  11.  
  12. function devise_filter_design_form() {
  13.     $selected = isset($_GET['pa_design']) ? $_GET['pa_design'] : '';
  14.     wp_dropdown_categories( array(
  15.         'taxonomy'         => 'pa_design',
  16.         'name'             => 'pa_design',
  17.         'show_option_none' => 'Фильтр по цвету',
  18.         'show_count'       => false,
  19.         'hide_empty'       => true,
  20.         'selected'         => $selected
  21.         )
  22.     );
  23. }
  24. add_action( 'restrict_manage_posts', 'devise_filter_design_form', 25 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement