Reece
Reece

Reputation: 2711

WooCommerce products not appearing unless using WP_Query

I have added four products to WooCommerce but none are showing up on the shop page. I can't even see the product if I click the link to view it in the backend. I have tried resetting the permalinks in settings and I have made sure that each products Catalog visibility is set to "Shop and search results". And I have also deactivated every plugin apart from WooCommerce and still no products on the front end.

The weird thing is that the products will show on any page that I use WP_Query like so:

<?php
    $params = array('posts_per_page' => 5, 'post_type' => 'product');
    $wc_query = new WP_Query($params);
?>
<?php if ($wc_query->have_posts()) : ?>
    <?php while ($wc_query->have_posts()) :
        $wc_query->the_post(); ?>
    <?php the_title(); ?>
    <?php endwhile; ?>
    <?php wp_reset_postdata(); ?>
<?php else:  ?>

<p><?php _e( 'No Products'); ?></p>

<?php endif; ?>

Is there anything else I can try?

It seems the products only don't show on my custom theme. If I make one of the standard themes that come with wp active it shows the products. What is causing this?

Upvotes: 0

Views: 648

Answers (2)

raju_odi
raju_odi

Reputation: 1475

If You are using Custom theme then you have to add archive-product.php to your theme.

You can add that template by creating a folder in your theme name "Woocommerce" then in that folder copy archive-product.php from ---Plugins->Woocommerce->templates and paste in themes Woocommerce template.

(Note : you are running custom theme this is why issue occurs).

Upvotes: 1

Sharif Mohammad Eunus
Sharif Mohammad Eunus

Reputation: 834

Do your theme support woocommerce?

if yes did you set the shop page?

you will find the setting Dasbord->Woocommerce->settings>product->Shop pages

This link might help you

Upvotes: 1

Related Questions