Black Friday: Up to 40% off all plans!

Offer automatically applied at checkout
Days
Hours
Minutes
Seconds

FAQs

Find answers to common questions and step-by-step solutions.

Glossary

An alphabetical list of terms and their definitions.​

Video Library

Discover our tutorials

Filter: Set a Minimum Word Limit for Posts to be Imported

Note: These documents refer to features and updates in the upcoming v5 release, which will be available soon. Some information may not apply to earlier versions. Stay tuned for the official launch announcement!

Who can use this feature?

Users on

IN THIS ARTICLE
Learn how to set a minimum word limit for posts to be imported when using the Feed to Post feature.
Contents

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;
}

Learn how to add custom actions and filters to your site.

GIVE FEEDBACK

Was this article helpful?

Still stuck?

Find Your Perfect Plan

Answer a few questions, and we’ll recommend the best option for you!