I hope this is not too specific to WooCommerce.
I have a nifty shortcode that displays a list of all my products with SKUs. However, it also includes products that I have published but have set the catalog visibility to "hidden."
I can't find an argument / parameter to exclude hidden products (or only include those marked as Catalog/Search).
I know it must be simple; I just haven't found it. Thanks for any help.
Here is the code:
<?php $params = array('posts_per_page' => -1, 'post_type' => 'product', 'orderby' => 'menu-order', 'order' => 'asc'); $wc_query = new WP_Query($params); ?> <table class="product-list tablesorter"><thead><tr><th>SKU</th><th>Product Name</th></tr></thead><tbody> <?php if ($wc_query->have_posts()) : ?> <?php while ($wc_query->have_posts()) : $wc_query->the_post(); ?> <tr> <td><?php global $product; echo $product->get_sku(); ?></td> <td><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></td> </tr> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <?php else: ?> <tr><td> <?php _e( 'No Products' ); ?> </td> </tr> <?php endif; ?> </tbody> </table>