Is there any way to delete all the content of every post without actually deleting the post!
Suppose , I have articles
- how to install wordpress ?
- what is wordpress . . . . and so on
- 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 ?
Is there any way to delete all the content of every post without actually deleting the post!
Suppose , I have articles
- how to install wordpress ?
- what is wordpress . . . . and so on
- 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 ?
Share Improve this question edited Aug 7, 2015 at 7:09 Pieter Goosen 55.4k23 gold badges116 silver badges210 bronze badges asked Aug 7, 2015 at 4:05 pradippradip 701 silver badge10 bronze badges1 Answer
Reset to default 1You 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.