Skip to main content

Delete Custom Post Type Plugin

If you want to develop a Plugin that delete the Custom Post Type then have a look at the given source code.

<?php
<!-- 
Plugin Name: DB Cleaner
Version: 1.0
Author: <a href="http://anwarkhan.co.nf">Anwar</a>
 -->
?>

<!-- Delete Custom Post Type -->

<?php
function remove_option_page(){
remove_menu_page('dit.php?post_type=movies');
}
add_action('admin_menu', 'remove_option_page', 99);

I am deleting Movies so code above is for movies.


Comments

Popular posts from this blog

How to Delete Custom Post Type Post through a Plugin

If you want to delete Custom Post Type Data/Posts then this Plugin will help you in deleting the required posts.So have a look at the Plugin that how does it works. <?php /* Plugin Name: CPT Data Cleaner Author: <a href=" http://anwarkhan.co.nf ">Anwar</a> Description: This is a starter Plugin developed by Skyline IT Solutions. Author URI:  http://anwarkhan.co.nf Version: 1.0 License:      GPL2 */ ?> <?php function delete(){ $delete_post = array(     'post_type'     => 'movies',     'name'    => $title,     'post_status'   => 'publish',     'post_author'   => $current_user->ID ); $posts = new WP_Query( $delete_post ); if ( $posts->have_posts() ) {     while ( $posts->have_posts() ) {         $posts->the_post();          wp_delete_post( get_the_ID());     } }  } add_action( 'admin_menu', 'delete' ); ?>