In some of Aggregator’s premium versions, the Feed to Post feature sets the plugin to import all qualified items from a source as posts or any custom post type. However, you might sometimes want to prevent posts with very short content from being imported for one reason or another.
The below filter allows you to set a minimum number of words for imported posts, meaning that if a post has less than the set number of words, it will not be imported to your site.
The number of words (“100” in the example below) can be changed to any limit you want.
add_filter( 'wprss_ftp_post_args', 'my_custom_post_args', 10, 2 );
function my_custom_post_args( $post, $feed_source ) {
$new_post = $post;
$post_content_word_count = str_word_count( $new_post['post_content'] );
if( $post_content_word_count < 100 ){
return NULL; // return null if number of words are less than 100
}
// Return the new post
return $new_post;
}