Filtering post content using wpseo_pre_analysis_post_content

wp seo
wp seo

If you are using WordPress, may it be for personal blogging or business, you would definitely want your site to be indexed well in organic searches. Whatever handful of experience I have, I know SEO is not everyone’s cup of tea, and believe me when I am saying this, because I, personally know a lot of people who doesn’t understand SEO and many others who doesn’t want to.

For such majority of people WP seo by yoast is like a life Saviour, it has everything well aligned to use and guides you step by step to work with the plugin. The plugin has great documentation to help you start with the plugin. I have been working with the plugin for couple of years now and it is only getting better.

WP seo works with content from the default editor area of the post/page but with custom post types there are times when a post type is not using the default content editor and rather using a custom field. This is when the SEO of the page drastically drops due to zero content and the plugin by yoast warns about the same.

Here is an image with a similar situation.


The first line in the image which reads “There are 0 words contained in the body copy. This is far too low and should be increased.” clearly points out how critically this affects your SEO.

To fix this issue we can use the wpseo_pre_analysis_post_content filter that the plugin provides. This filter let us change the content section the plugin should look for before analyzing the page for SEO. You can use the below code in your theme’s functions.php file. Needless to say but I would say it again, please please make your custom changes using a child theme, so add the below snippet in your child theme’s functions.php file.

The above snippet is made to work for post type ‘recipes’ which was my requirement and gets content from a custom field. After using this, the same page shows a great sign of improvement in the analysis. The below image would show you the difference.


If you have any questions regarding the blog please let me know below in the comments.


Maruti Mohanty

I am a happy go lucky WordPress Developer, who loves biking, movies and learning different languages


You may also like...

2 Responses

  1. Matt says:

    Great post – I’m just wondering where you placed the wpseo_pre_analysis_post_content filter? I’ve been having all kinds of issues with avia builder.

    • Hi Matt,

      Ok I see. I should have mentioned it. You can use the snippet in your child theme’s functions.php file.

      I am editing the post to include this info. Thanks for bringing this up.


Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: