Custom Product Loop – Exclude "Hidden" Products
-
Hello.
I’m using a theme that has a custom product loop on the home page. Everything is great except “hidden” and/or “private” products are showing on the home page. Can someone please look at this code and let me know what to add in order to exclude “hidden” products.
<?php if (of_get_option("cap_show_merch") == true){?> <?php //woocommerce check ?> <?php if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { ?> <h2><?php echo of_get_option("cap_merch_title"); ?></h2> <div class="preview-block"> <?php global $product; $num = 0; $merch = new WP_Query( array( 'posts_per_page' => 5, 'post_type' => array( 'product' ) ) ); if( $merch->have_posts() ) : while( $merch->have_posts() ) : $merch->the_post(); $product = get_product(); if ( $num == 0 ) : ?> <div class="preview"> <div class="visual"> <?php if ( has_post_thumbnail() ) : ?> <img src="<?php echo aq_resize( wp_get_attachment_url( get_post_thumbnail_id(), 'full' ), 473, 453, true ); ?>" width="473" height="453" alt="<?php the_title(); ?>" /> <?php else : ?> <img src="<?php echo woocommerce_placeholder_img_src(); ?>" alt="Placeholder" /> <?php endif; ?> <a href="<?php the_permalink(); ?>" class="mask"></a> <?php woocommerce_template_loop_price(); ?> </div> <a href="<?php the_permalink(); ?>" class="caption"><?php the_title(); ?></a> </div> <?php else : ?> <?php if ( $num == 1 ) : ?> <ul class="catalog"> <?php endif; ?> <li> <div class="visual"> <?php if ( has_post_thumbnail() ) : ?> <img src="<?php echo aq_resize( wp_get_attachment_url( get_post_thumbnail_id(), 'full' ), 222, 193, true ); ?>" width="222" height="193" alt="<?php the_title(); ?>" /> <?php else : ?> <img src="<?php echo woocommerce_placeholder_img_src(); ?>" alt="Placeholder" /> <?php endif; ?> <a href="<?php the_permalink(); ?>" class="mask"></a> <?php woocommerce_template_loop_price(); ?> </div> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </li> <?php endif; $num++; endwhile; ?> </ul> <?php endif; wp_reset_postdata(); ?> </div><!--preview-block--> <?php } //woocommerce check?> <?php } ?>
This is the theme https://demo.mintthemes.com/soundstage/
Thank you very much.
Nick
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Custom Product Loop – Exclude "Hidden" Products’ is closed to new replies.