0
我想从我的Wordpress网站上的Woocommerce获取产品数据。我使用下面的代码来获取特定类别产品的名称和缩略图。从Wordpress获取属性数据
<?php
$args = array('post_type' => 'product', 'posts_per_page' => 10, 'product_cat' => 'Tools');
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post();
global $product;
echo '<br /><a href="'.get_permalink().'">' . woocommerce_get_product_thumbnail().' '.the_title().'</a>';
endwhile;
wp_reset_query();
?>
这可以很好地获取产品的名称和图像类别“工具”,但我想要获得每个产品的重量。
产品重量在Wordpress仪表板中设置为产品属性。
如何获取产品的这些数据?我似乎无法找到访问这些功能的功能。
这应有助于:http://stackoverflow.com/questions/13374883/woocommerce-getting-custom-attributes –