• Hi there,
    I am trying to limit the content size to something like the 200-word limit. This way I the plugin doesn’t look for an entire post_content.
    How do I do it?
    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Michael Nelson

    (@mnelson4)

    Hi @slamsal, YARPP kinda already has you covered here. When searching for related posts from a “reference post”, it looks for the 20 most common words (that aren’t stop words like “the”, “from”, “by”, etc) and only uses those for comparison. You can see the code in classes/YARPP_Cache.php, in the function extract_keywords.

    So I don’t think the optimization you’re thinking of is necessary, because YARPP only compares using 20 words by default.

    Does that make sense?

    Thread Starter slamsal

    (@slamsal)

    Because I’m aggregating lots of article from around the web in one post but the title and generally the first two paragraphs are always related to the title of post and rest of content is usually unrelated.
    I’m currently doing something like this:

    
    	return apply_filters( 'yarpp_body_keywords', $this->extract_keywords( apply_filters( 'the_content', wp_trim_words( $post->post_content, 120 )  ), $max, $ID ), $max, $ID );
    
    

    Please let me know if you think I did it right.
    Thank you again!

    Plugin Support Michael Nelson

    (@mnelson4)

    Hi @slamsal ahh I see, so it’s not an efficiency issue, gotcha.

    What you’re doing there will work… until the next time YARPP is updated, and your changes get overwritten by the update.

    I looked into it and it’s quite hard to do that with the current codebase. We’re discussing what changes could be made to make it easier to customize what words YARPP uses when evaluating relatedness.
    `

    Thread Starter slamsal

    (@slamsal)

    Awesome! Looking forward to the updates.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Limit post bodies size’ is closed to new replies.