admin管理员组文章数量:1291124
So, I've tried on my website. It works good, as long as all the products have SKU. If a product doesn't have SKU, it's not displayed at all.
This being said, is there any other way to sort by SKU but not require product to actually have SKU?
So, I've tried https://gist.github/bekarice/1883b7e678ec89cc8f4d on my website. It works good, as long as all the products have SKU. If a product doesn't have SKU, it's not displayed at all.
This being said, is there any other way to sort by SKU but not require product to actually have SKU?
Share Improve this question asked Jun 8, 2021 at 4:26 errorouserrorous 1691 silver badge9 bronze badges1 Answer
Reset to default 1To use with woocommerce plugin and theme already css and code.
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => -1,
'meta_key' => '_sku',
'orderby' => 'meta_value',
'order' => 'DESC',
);
query_posts( $args );
if( have_posts() ) :
while (have_posts()): the_post();
wc_get_template_part( 'content', 'product' );
endwhile;
endif;
wp_reset_query();
本文标签: wp queryWooCommerce sort by SKU
版权声明:本文标题:wp query - WooCommerce sort by SKU 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741516066a2382896.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论