try with this :
$args = array (
'post_type' => 'book',
'nopaging' => true
);
$myquery = new WP_Query ($args);
while ($myquery->have_posts ()) {
$myquery->the_post ();
$id = get_the_ID ();
wp_delete_post ($id, true);
}
wp_reset_postdata ();
let me know if this works for you!
Related Posts:
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- How can I add an image upload field directly to a custom write panel?
- Looking for WordPress System Diagrams
- How to output message during plugin activation
- On the WordPress Admin section how do I link to submenu pages created for a plugin?
- How to return only certain fields using get_posts()
- How to provide translations for a WordPress TinyMCE plugin?
- Where do I start from
- Where is it better to start learning how to develop for WordPress?
- Check the Version of an Enqueue’d External Library
- Is there any way to test if a function running only on plugin update is successfully running?
- Using wp_cron with custom time interval and the register activation hook
- Throw 403 in a plugin [duplicate]
- Change of query var in pre_get_posts not maintained
- Hook for post permalink update
- Menu Error in Admin Console with Custom Plugin: You do not have sufficient permissions to access this page
- How to Parse an Array of Elements in Gutenberg Block
- Load page template with custom content using a plugin
- How to put placeholder text in the main post input area?
- Custom rewrite rule serves content, but returns 404 error code
- Will changing the ‘Plugin Name’ header in the next update of a plugin break anything?
- Performance of several get_option() calls
- How to edit mySQL wp_posts table from plugin php?
- Creating a Wordpess Plugin that writes data to a csv file. The data doesn’t show in the csv file?
- how to redirect to another post without getting headers already sent error?
- Problem with is_active_sidebar?
- Prevent Plugin from loading on ‘wp-admin / wp-login’
- Redirect user to a particular link in 10 seconds after using wp_die
- Widget update function not saving values
- Getting admin notices working for plugin errors
- Change template dynamically
- override pluggable.php functions
- An echo line in a transition_post_status action leads to “cannot modify header information – headers already sent by”
- get_the_excerpt() is not returning an empty string when the_excerpt is blank?
- “Plugin could not be activated because it triggered a fatal error.”
- Programmatically detect if wp-cron is disabled?
- Does the order of sections in readme.txt matter?
- Add column in WP user but it goes wrong
- How to remove the current post from the query?
- Passing nonce at admin menu link
- Is file_get_contents() the only way for plugins reading local files OR does WP_Filesystem_Direct::get_contents() even work?
- how to get up row in wordpress with wpdb
- Preview plugin store details
- Prevent third party plugin’s admin page access based on user type
- Hook into Jetpacks Publicize without using a post type
- Get attachments from a post
- How to remove default style of header in wordpress metabox
- I have 2 plugins using the same wp_login action hook and one is not working
- TEMPLATEPATH without the theme name? No THEMEPATH constant?
- wp_update_post deletes post meta in CPT
- Update Data parameter of a wp_localize_script() call
- Checking a WordPress for OWASP top 10 vulnerabilities [closed]
- flush rewrite rules after plugin update?
- Download button in a plugin’s settings page
- hook filter after the_content on a specific page
- The Correct Way to Use Nonce Field without Settings API
- Run command “composer install” when activating wordpress plugin
- Data not insert and update through ajax and jQuery in admin page?
- Full documentation about $args for register_rest_route?
- Import user data using CSV
- WP Plugin with Upgrade option
- How to submit/upload data to database and in specific folder?
- OOP plugin not working
- Plugin settings are saving but the fields
- Plugin Options not saving options and doesn’t work
- WordPress dynamic widget by location?
- Bootstrap Error in WordPress plugin
- JQuery Slider – Similar to www.internetmarketinginc.com [closed]
- wp_enqueue_scripts in a plugin’s class
- Proper way to create an administration page without adding it to the menu
- Development plugin to view and manage scheduled wordpress cron jobs?
- Add user managable titles to custom menus?
- Custom Icon for Plugin
- WP_Query order posts by category
- How to override supports of innerBlocks?
- Implications of creating a plugin that adds functionality to other developer’s plugin?
- First page download plugin
- why is update_user_meta creating arrays when trying to change the same value?
- Load custom translation in custom plugin fails
- Buddy Press restrict the capability to edit users
- “Headers Already Sent” Nightmare on Plugin
- Uncaught ReferenceError: kpoejy is not defined
- How to get an array out of a nav menu if it’s a plugin?
- Is there better way to do this without duplicating queries?
- How to create a simple plugin which show/hide an html code in wordpress?
- Is there a way to make is_search() always return false
- How to create custom frontend php page via plugin
- How can I add recent posts to menu like mashable
- Translation of plugin Upload button
- Changing upload directory for plugin uploads only
- Create wordpress dashboard metabox which spans all columns
- add_filter adds output in the head
- How can i add insertion point between inner blocks in my custom block like core blocks
- Update option hook not firing
- $_GET vs get_query_var()
- Is there a canonical way for a plugin to install a mu-plugin or drop-in?
- How can create a custom plugin to call my webapi after any registration or membership plugin functionality
- Calling get_header() with installed FSE theme
- Reinitiate Gutenburg’s blocks using javascript
- Generating Multiple Divi Pages from Database