Created
June 19, 2020 12:28
-
-
Save felipe-pita/d1513993b9eb0ab97deb830f346a64cb to your computer and use it in GitHub Desktop.
Woocommerce list all products catalog visibility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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