One of the most common problems in WooCommerce is duplicate WooCommerce product showing up on page. If you are running into this problem, I want to show you the possible causes of this issue and how you can easily fix it without wasting all your time.
To understand why duplicate WooCommerce product showing up on page occurs you need to first understand how WooCommerce products are displayed on the home page or on any other page.
I want to begin by showing you how you can display WooCommerce products.
WooCommerce Products Display
WooCommerce products are displayed using a loop and this can be illustrated using the code below that has been added to the custom page template and you can see the display of the products in the image below :
For these products to be displayed on this page, I have created a custom page template and added the loop that queries the WooCommere products and displays them as in the cide below:
/**
* Template Name: Testing Page
*
* @package WordPress
*/
get_header();
$args = array(
‘post_type’ => ‘product’,
‘posts_per_page’ => 4,
);?>
<div class="test-loop">
<?php
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
global $product;
?>
<div class="test-loop-item">
<a href="<?php the_permalink(); ?>" id="id-<?php the_id(); ?>" title="<?php the_title(); ?>">
<?php if (has_post_thumbnail( $loop->post->ID ))
echo get_the_post_thumbnail($loop->post->ID, ‘shop_catalog’);
else echo ‘<img src="’.woocommerce_placeholder_img_src().’" alt="product placeholder Image" width="65px" height="115px" />’; ?>
<h3>
<?php the_title(); ?>
</h3>
</a>
</div>
<?php
endwhile;
wp_reset_query(); ?>
</div>
<?php get_footer(); ?>
[/php]Duplicate WooCommerce Product Showing up on Page
We can recreate this problem of duplicate WooCommerce product showing up on page by repeating the loop that displays the products on the page. This is the cause of the problem of WooCommerce product showing up on page.
There are several cases that can lead to this issue, the most common cause in my experience is a translation plugin that recreates the product in a different language.
The second most common cause of this problem is the plugin that uses the loop to display products. The best way to fix this problem is to remove all the plugins and reactivate them one by one checking which one is causing the issue.
The second cause of this issue is a theme that has some loop code that is added to the page especially on the footer or header and this can use tested by creating a custom page template and testing to see if the duplicate products are displayed on the blank custom page template.
Conclusion
In this post we have looked at how to fix duplicate WooCommerce product showing up on page, ideally, you want to figure out what is causing the loop that displays the WooCommerce products on the page to be repeated.
Joe is an experienced full-stack web developer with a decade of industry experience in the LAMP & MERN stacks, WordPress, WooCommerce, and JavaScript – (diverse portfolio). He has a passion for creating elegant and user-friendly solutions and thrives in collaborative environments. In his spare time, he enjoys exploring new tech trends, tinkering with new tools, and contributing to open-source projects. You can hire me here for your next project.
Similar Articles
- How to Fix Checkout Is Not Available Whilst Your Cart Is Empty WooCommerce
- How to Add WooCommerce My Account Page Redirect
- How to Get Current WooCommerce Product Category
- How to Add Text after Price in WooCommerce » Add Price Suffix
- How to Get Category URL WooCommerce
- Elementor Review 2021 » Features, Pros, Cons, Pricing & Tutorial
- How to Get Product Description & Display WooCommerce
- How to Customize WooCommerce Order Received Page
- How to Delete Uncategorized Product Category WooCommerce
- How to Create WordPress Pagination for Custom Post Types
- How to Display All Products With No Weight WooCommerce
- How to Create Custom Query Pagination In WordPress With an Example
- Top 11+ Best Ecommerce Platform » Best Online Store Platforms for Small Business
- How to Duplicate a Product in WooCommerce
- How to Create Custom Order Received Page WooCommerce
- How to Create Custom Logs in WooCommerce
- How to Delete a Page In WordPress
- How to Create WooCommerce Lost Password Shortcode