1

Is there any way to delete all the content of every post without actually deleting the post!

Suppose , I have articles

  1. how to install wordpress ?
  2. what is wordpress . . . . and so on
  3. What is plugin ?

Suppose , I want to delete all the contents of each article without actually deleting the post.

The title , the tag , the category should remain. Only the content should be deleted.

How can this be done ?

1

You can run this MySQL query to empty post content.

UPDATE wp_posts SET post_content='';

make sure you have a backup before you run this query, in case you need it later. Also make sure that your MySQL table prefix is wp_.

Another Method.

You can also use WP_Query custom query to remove post content.

$args = array(
  'post_type' => array( 'post', 'page' ),
  'posts_per_page' => '-1',
);

$my_query = new WP_Query( $args );

if ( $my_query->have_posts() ) :
  while ( $my_query->have_posts() ) : $my_query->the_post();

    wp_update_post( array(
      'ID'            => get_the_id(),
      'post_content'   => '',
    ) );

  endwhile;
endif;

wp_reset_postdata();

You can use any of the above method. Both are working, just tested them.

  • @pradip So did it work? – Robert hue Aug 10 '15 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.