I have around 2000 custom posts. And 7 regular wp pages. I want to delete all those custom post without effecting the pages. I thought the easiest way would be to empty the custom post table but I dont know how to do it. I am familiar with DB operations but I dont know the schema of wp posts, so have no idea where these custom posts are located. I don’t mind using a plugin to do it.
Inshort:- Just want to delete all the custom posts and their data.
4 Answers
I used a custom page template to delete all the post from the wordpress database.
Everytime I would go to this page it would delete 300 posts.The code for the page template is:
<?php
// Get 300 custom post types pages, set the number higher if is not slow.
$mycustomposts = get_posts( array( 'post_type' => 'movies', 'numberposts' => 300));
echo '<pre>';
print_r($mycustomposts);
echo '</pre>';
foreach( $mycustomposts as $mypost ) {
// Delete's each post.
wp_delete_post( $mypost->ID, true);
// Set to False if you want to send them to Trash.
}
echo '<h1 style=:"color:red;"> DELETED! DELETED! DELETED! DELETED! </h1>';
// 300 custom post types are being deleted everytime you refresh the page.?>