Including post thumbnail url in loop's post object to reduce number of queries

by TheDraom   Last Updated May 15, 2019 22:08 PM

I'm working now on high performance Wordpress website and it requires me to analyze a lot of queries, caching options etc. I've discovered that if you use get_the_post_thumbnail() even within the loop, then WordPress makes a query for every post's thumbnail url.

So if you've got your page set to display 25 posts with thumbnails, it makes 25 additional queries to retrieve image URL.

Without using get_the_post_thumbnail() I'm reducing query number from 49 to 4. A big number. However, thumbnails are really needed for this theme.

Do you know if there's any way to include post thumbnail URL in the post object by default?

Related Questions

Updated February 26, 2017 05:08 AM

Updated February 20, 2017 03:08 AM

Updated May 14, 2016 08:03 AM

Updated April 26, 2017 06:08 AM

Updated November 28, 2017 04:08 AM