Created
October 17, 2018 15:46
-
-
Save eto4detak/739d36d3fc10cacb334f5e81bd447030 to your computer and use it in GitHub Desktop.
woo delete product
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
<?php | |
$args = array( | |
'post_type' => array( 'product_variation',), | |
// 'post_status' => array( //(string / array) - use post status. Retrieves posts by Post Status, default value i'publish'. | |
// // 'publish', // - a published post or page. | |
// // 'pending', // - post is pending review. | |
// // 'draft', // - a post in draft status. | |
// // 'auto-draft', // - a newly created post, with no content. | |
// // 'future', // - a post to publish in the future. | |
// // 'private', // - not visible to users who are not logged in. | |
// // 'inherit', // - a revision. see get_children. | |
// // 'trash' // - post is in trashbin (available with Version 2.9). | |
// ), | |
'posts_per_page' => -1, | |
); | |
$the_query = new WP_Query( $args ); | |
// The Loop | |
global $post; | |
if ( $the_query->have_posts() ) : | |
var_dump($the_query->posts); | |
while ( $the_query->have_posts() ) : $the_query->the_post(); | |
wp_delete_post($post->ID); | |
endwhile; | |
endif; | |
// Reset Post Data | |
wp_reset_postdata(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment