Last active
July 2, 2020 14:56
-
-
Save 1naveengiri/abd388dd38b469f30132a61c18c6d82e to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* Plugin Name: Delete GD post | |
* Plugin URI: http://buddydevelopers.com | |
* Description: plugin to delete Gd posts | |
*/ | |
/** | |
* Place this file in wp-content/mu-plugins/ folder. | |
* | |
* Run command | |
* wp gddelete post | |
***/ | |
/** | |
* Class to plugin to delete Gd posts | |
*/ | |
if ( defined( 'WP_CLI' ) && WP_CLI ) { | |
class GD_Delete_Post_Command extends WP_CLI_Command { | |
/** | |
* upload video poster image by url given. | |
* @return none | |
*/ | |
public function post(){ | |
$args = array( | |
'post_type' => 'gd_place', | |
'posts_per_page' => 1 | |
); | |
$query = new WP_Query( $args ); | |
// The Loop | |
$the_query = new WP_Query( $args ); | |
if ( $the_query->have_posts() ) { | |
while ( $the_query->have_posts() ) { | |
$the_query->the_post(); | |
$post_id = get_the_ID(); | |
WP_CLI::log( 'Place ID: ' . $post_id ); | |
wp_delete_post( $post_id, true); | |
WP_CLI::log( 'Place deleted' ); | |
} | |
wp_reset_postdata(); | |
WP_CLI::success('Successfully deleted all Place'); | |
} | |
} | |
} | |
WP_CLI::add_command( 'gddelete', 'GD_Delete_Post_Command' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment