How to empty wordpress custom post Database table

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.?>

Leave a Comment