Hello, I need to hide products with same title from WooCommerce shop page so i created a loop which is working and does hide products with same name but i have a problem. If i set posts_per_page=8 it shows less because it counts the hidden products also. <?php $args = array('post_type'=>'product','posts_per_page'=>8); $query =new WP_Query($args); $list = array(); while($query->have_posts()): $query->the_post();if(in_array(get_the_title(), $list)){continue;} $list[]= get_the_title();?> <li><?php wc_get_template_part('content','product');?></li> <?php endwhile; wp_reset_postdata(); ?> Code (markup): Any ideas?
If you can't get the query to exclude the dupes then you'll need to request more than 8, take out the dupes, and then show the first 8. Creates havoc with paging so do everything you can to get the query to manage the dupes.
You probably should't try to do this. there, corrected ... and people wonder why I say WP's built in database wrapping is 3i -- ignorant, incompetent, and inept. It just teaches people how NOT to do things.