Friday 3 February 2023

Deletes all posts from "products" custom post type.

 /**

* Deletes all posts from "products" custom post type. */ function wpdocs_delete_all_products() { $myproducts = get_pages( array( 'post_type' => 'products') ); foreach ( $myproducts as $myproduct ) { // Delete all products. wp_delete_post( $myproduct->ID, true); // Set to False if you want to send them to Trash. } } add_action( 'init', 'wpdocs_delete_all_products' );

No comments:

Post a Comment