Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save felipe-pita/d1513993b9eb0ab97deb830f346a64cb to your computer and use it in GitHub Desktop.
Save felipe-pita/d1513993b9eb0ab97deb830f346a64cb to your computer and use it in GitHub Desktop.
Woocommerce list all products catalog visibility
/**
* Lista a visibilidade do catálogo de todos os itens
*/
add_action('admin_post_check_products_visibility', 'check_products_visibility');
function check_products_visibility() {
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
);
echo '<pre>';
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post();
$product = wc_get_product(get_the_id());
if ($product->get_catalog_visibility() == 'hidden')
echo '<br>' . get_the_title();
endwhile;
wp_reset_query();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment