Created
March 7, 2022 10:58
-
-
Save Oscar-Abad-Folgueira/856fda4e11f7469ac65317c1bc2937eb to your computer and use it in GitHub Desktop.
WordPress Snippet: Borrar todos los posts con código
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @snippet WordPress Snippet: Borrar todos los posts con código | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://www.oscarabadfolgueira.com/como-crear-tareas-programadas-en-wordpress--cron-jobs/ | |
*/ | |
function oaf_borrar_todos_posts(){ | |
$todos_posts = get_posts( array('post_type'=>'post','numberposts'=>-1) ); | |
foreach ($todos_posts as $unpost) { | |
wp_delete_post( $todos_posts->ID, true ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment