How to make dynamically-generated content searchable in WordPress?

The wp_posts table has a post_content_filtered column that plugins can use to cache expensive post content filters. The idea is that when you display the page, you don’t read post_content but you read post_content_filtered. This is nice, but it won’t solve your search problem because WordPress by default only looks at post_content and post_title.

You can however do it the other way around: store the editor content in post_content_filtered and the rendered page in post_content (update it periodically with a cron job). There are filters that are called before the post is edited, you can use them to pass post_content_filtered instead of post_content to the editor. So the user will see no difference, but the performance and the search experience will be improved.

Leave a Comment