I searched a lot about this, found plugins that are out dated and consumes massive resources and finally do nothing, is there like an SQL line to delete all posts that have a word count like less than 100 words?
Thanks,
I searched a lot about this, found plugins that are out dated and consumes massive resources and finally do nothing, is there like an SQL line to delete all posts that have a word count like less than 100 words?
Thanks,
Share Improve this question asked Nov 19, 2018 at 4:20 Abdelrahman EllithyAbdelrahman Ellithy 11 bronze badge 2 |1 Answer
Reset to default -1function delete_posts() {
$lastposts = get_posts(array('numberposts' => -1));
if ( $lastposts ) {
foreach ( $lastposts as $post ) :
setup_postdata( $post ); ?>
<?php
$content = get_the_content();
if (str_word_count($content) < 100) {
wp_trash_post($post->ID);
}
?>
<?php
endforeach;
wp_reset_postdata();
}}add_action( 'init', 'delete_posts' );
) and can be used as word separators... Also you can have HTML tags inside your content - how should that be counted? – Krzysiek Dróżdż Commented Nov 19, 2018 at 7:53