我创建了一个循环,应该显示图像、名称/标题和产品的价格。我成功地显示了图片和名称/标题,但没有显示价格。我的PHP知识不是很好,但我想知道我错在哪里。这是我当前的代码:
<?php
foreach ($category_slugs as $category_slug){
$products = woo_site_builder_get_products_by_category($category_slug);
if($products):
echo "<ul id=\'$category_slug\'>";
foreach ($products as $product):
$product_image = wp_get_attachment_url(get_post_thumbnail_id($product->get_id()));
if(!$product_image) continue;
echo \'<li class="structural-elements" data-category="\'.$category_slug.\'" data-productid="\'.$product->get_id().\'"><span>\'.get_the_title($product->get_id()).\'</span><span class="price_section">\'.get_price($product->get_id()).\'</span><img src="\'.$product_image.\'"></li>\';
endforeach;
echo "</ul>";
endif;
}
?>