Woocommerce:获取所有SKU产品的列表 [英] Woocommerce: get a list for all sku product

查看:491
本文介绍了Woocommerce:获取所有SKU产品的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在<li>列表中获得电子商务中所有的sku. 我相信我应该使用foreach循环,但是我不知道该如何回忆所有产品的选择.

I would to get in a <li> list all sku there are in an ecommerce. I belive that I should use foreach cycle, but I don't know how to recall the selection of all products.

感谢所有答复,对不起我的英语不好. 特色

Thanks for all reply, and sorry for my bad english. Greatings

推荐答案

请尝试此操作.让我知道这是否完美;)

Please try this. Let me know if this works perfectly ;)

$args = array( 'post_type' => 'product', 'posts_per_page' => -1 );
query_posts( $args );
if( have_posts() ):
    echo '<ul>';
    while ( have_posts() ) : the_post();
        echo '<li>'. $product->get_sku() . '</li>';
    endwhile;
    echo '</ul>';
endif;

干杯!

这篇关于Woocommerce:获取所有SKU产品的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆