Bulk delete/edit excerpts in WordPress?

I’ve taken over and built a new theme utilizing all the goodies WordPress comes with. I’m also using the built-in excerpts functions within WordPress… however, the previous user wasn’t using automatic excerpts and was manually typing their own excerpts.

I was wondering if there is a method to either override the manual excerpts or to perform a bulk edit on the excerpts?

Related posts

Leave a Reply

2 comments

  1. Use the query

    UPDATE wp_posts SET post_excerpt=''
    

    in phpmyadmin. Change the table prefix in the query if the default prefix of wp_ isn’t being used. Backup your database first.

    Or:

    If you don’t want to use phpmyadmin, run the MySQL query as a $wpdb PHP function.

    Put this at the bottom (or top) of your functions.php file and reload the site:

    $wpdb->query( "UPDATE wp_posts SET post_excerpt='' " ); 
    

    Or put this in a template file, like index.php, and reload the page:

    <?php $wpdb->query( "UPDATE wp_posts SET post_excerpt='' " ); ?>
    

    And of course, remove either of those PHP functions from the file after you run them.

    Edit: and, it’s a good idea to select for the post type of posts when using the query, as Murilo Pontes in his answer; otherwise, plugins and other functions that may use the excerpt for data storage will lose their data.

  2. Don’t use “UPDATE wp_posts SET post_excerpt=” “. That can break things (like email templates) if post_type is not configured
    Use the following querys instead.

    View excerpts
    SELECT post_excerpt FROM wp_posts WHERE post_type=’post’

    Update excerpts to ”
    UPDATE wp_posts SET post_excerpt=” WHERE post_type=’post’