2017-09-28 12 views
0

バージョン3.0以降、Woocommerceはバックエンドの特集商品のソートオプションを削除しました。私はここでこの解決策を試しましたが、それ以上は機能していないようです。https://wordpress.stackexchange.com/questions/104537/woocommerce-filter-by-featured-products-in-adminWoocommerce - 管理者のおすすめ商品によるフィルタ

素晴らしいドロップダウンフィルタが作成されましたが、残念ながら注目の製品は除外されていません。

私たちは2000以上の製品を持っているので、それらを一つずつ探すのはとても面倒です。私たちの特集商品を並べ替えたり、フィルターをかける方法はありますか?

おかげ

答えて

1

[OK]を、ここで仕事ができることと、ボーナスとして、あなたが在庫品のうち、フィルタリングすることができ、定格製品

add_action('restrict_manage_posts', 'featured_products_sorting'); 
function featured_products_sorting() { 
    global $typenow; 
    $post_type = 'product'; // change to your post type 
    $taxonomy = 'product_visibility'; // change to your taxonomy 
    if ($typenow == $post_type) { 
     $selected  = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : ''; 
     $info_taxonomy = get_taxonomy($taxonomy); 
     wp_dropdown_categories(array(
      'show_option_all' => __("Show all {$info_taxonomy->label}"), 
      'taxonomy'  => $taxonomy, 
      'name'   => $taxonomy, 
      'orderby'   => 'name', 
      'selected'  => $selected, 
      'show_count'  => true, 
      'hide_empty'  => true, 
     )); 
    }; 
} 
add_filter('parse_query', 'featured_products_sorting_query'); 
function featured_products_sorting_query($query) { 
    global $pagenow; 
    $post_type = 'product'; // change to your post type 
    $taxonomy = 'product_visibility'; // change to your taxonomy 
    $q_vars = &$query->query_vars; 
    if ($pagenow == 'edit.php' && isset($q_vars['post_type']) && $q_vars['post_type'] == $post_type && isset($q_vars[$taxonomy]) && is_numeric($q_vars[$taxonomy]) && $q_vars[$taxonomy] != 0) { 
     $term = get_term_by('id', $q_vars[$taxonomy], $taxonomy); 
     $q_vars[$taxonomy] = $term->slug; 
    } 
} 
ようだコードがあります
関連する問題