Created
February 27, 2021 19:35
-
-
Save FrancoStino/db512ee303743ac160f6f4649b0a0df8 to your computer and use it in GitHub Desktop.
Display List of Products With No Gallery Image @ WP Dashboard > Products
This file contains hidden or 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
<? | |
/** | |
* @snippet Display List of Products With No Gallery Image @ WP Dashboard > Products | |
*/ | |
add_action( 'admin_notices', 'products_no_weight_admin' ); | |
function products_no_weight_admin(){ | |
global $pagenow, $typenow; | |
if ( 'edit.php' === $pagenow && 'product' === $typenow ) { | |
echo '<div class="notice notice-warning is-dismissible"><h3 class="dashicons-before dashicons-warning">PRODOTTI SENZA GALLERIA DI IMMAGINI</h3><ul>'; | |
$args = array( | |
'status' => 'publish', | |
'visibility' => 'visible', | |
'limit' => -1 | |
); | |
$products = wc_get_products( $args ); | |
foreach ( $products as $product ) { | |
if ( ! $product->get_gallery_image_ids() ) { | |
echo '<li><a href="' . esc_url( get_edit_post_link( $product->get_id() ) ) . '">' . $product->get_name() . '</a></li>'; | |
} | |
} | |
echo '</ul></div>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment