I am creating a custom Theme that uses Woocommerce. On the frontage I have a loop that display the 12th newest products. I also created a custom template for Woocommerce but I can't display some info (like the price or the image) but I can display the title or the permalink for example.

Here is my loop (front-page.php) :

  $args = array(
  $loop = new WP_Query($args);
  if($loop->have_posts()) {
    while($loop->have_posts()) {
      wc_get_template_part("content", 'carousel');
  } else {
    echo 'No products found';

and here is my template (content-carousel.php) :

<div class="item">
  <div class="img"></div>
  <h2><?php the_title(); ?></h2>
    <span class="sale-price"><?php echo $product->get_price_html(); ?></span>
    <span class="old-price">Old Price</span>
  <a href="<?php the_permalink(); ?>"><div class="button see">More Information</div></a>
  <a href="#!"><div class="button">+ 1</div></a>

For example the price in .sale-price will create an error and stop displaying the other products after.

When .sale-price have content .sale-price have content

When .sale-pice is empty enter image description here

1 Answer 1


First of all, get_price_html() outputs html code for product price. To get sale price specifically, use get_sale_price() instead, and get_price() to get regular price.

Use Chrome web dev tool to inspect for any php error. The Loop breaks after outputing title, so my guess would be to look for error there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.