I want to display some information from database in each post, for example date of registration of user and user role etc. It is quite static data that doesn't change.

Now if I make a query to the database to get the above data, the post loop will fetch that data from database for each post (for example if a user has 20 posts on a page, it will fetch the very same data 20 times).

Is there a way to optimize this, to cache somehow?

Note: The is not about the loop or any cache plugin, just in general if some static query data can be optimized.

1 Answer 1


This is probably not the most optimal solution, but you could store static metadata as an array in the theme options. The options table is loaded in memory by default, giving you fast access.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.