小编use*_*291的帖子

Woocommerce Admin按库存/缺货过滤

我发现了一些代码(下面),我修改了这些代码,以便在woo commerce的产品页面上添加一个额外的过滤器,以便按库存和缺货过滤.我可以脱机工作,但只是无法弄清楚如何让它在库存中工作..我知道这与这条线'In Stock'=>'= <1'有关,但无法弄清楚是什么它应该是.非常感谢帮助

    <?php

add_action( 'restrict_manage_posts', 'wpse45436_admin_posts_filter_restrict_manage_posts' );
/**
 * First create the dropdown
 * make sure to change POST_TYPE to the name of your custom post type
 * 
 * @author Ohad Raz
 * 
 * @return void
 */
function wpse45436_admin_posts_filter_restrict_manage_posts(){
    $type = 'product';
    if (isset($_GET['post_type'])) {
        $type = $_GET['post_type'];
    }

    //only add filter to post type you want
    if ('product' == $type){
        //change this to the list of values you want to show
        //in 'label' => 'value' format
        $values …
Run Code Online (Sandbox Code Playgroud)

wordpress filtering woocommerce

4
推荐指数
1
解决办法
3873
查看次数

标签 统计

filtering ×1

woocommerce ×1

wordpress ×1