How can I display the product variations for each product within a loop such as the one on the Shop page? Is there any function that I can add to the content-product
template that retrieves the list of variations and displays them?
WooCommerce:显示循环内的产品变化
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- douxin0251 2017-11-05 12:37关注
Best way to do this is alter the loop. Something like that will help:
function filter_wc_query($query_args){ if(is_archive()){ //here you can use any conditional function to show variations on $query_args[] = ['post_parent'=> '*']; } return $query_args; } add_filter('woocommerce_get_query_vars','filter_wc_query');
Or if you want to this on view level: https://gist.github.com/lukecav/2470d9fe6337e13da4faae2f6d5fe15f
In this solution image you can grab by standard WP function:
get_post_thumbnail($product->ID,'shop_list');
But remeber that variation link will bring user to parent product and force him to select variation once more.
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 关于#.net#的问题:End Function
- ¥15 无法import pycausal
- ¥15 VS2022创建MVC framework提示:预安装的程序包具有对缺少的注册表值的引用
- ¥15 weditor无法连接模拟器Local server not started, start with?
- ¥20 6-3 String类定义
- ¥15 嵌入式--定时器使用
- ¥20 51单片机学习中的问题
- ¥30 Windows Server 2016利用兩張網卡處理兩個不同網絡
- ¥15 Python中knn问题
- ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库