Quick Tip: Beware of the_content Filter

Here’s a quick tip! Don’t apply the_content filters because some plugins (especially social share plugins) will use that filter to add something extra before or after your content, assuming it’s your main post or page content, which is fair. I’m also pretty sure that attachment posts can add things like images there too.

So if you’re using the_content filter somewhere in your footer for example, to allow automatic paragraphs and perhaps shortcodes, you’re better off with wpautop and do_shortcode. You can also create your own unique filter tag with apply_filters and then add the two functions to your new filter with add_filter.

About the author

Konstantin Kovshenin

WordPress Core Contributor, ex-Automattician, public speaker and consultant, enjoying life in Moscow. I blog about tech, WordPress and DevOps.