get_the_foo() in the loop – does it perform another query?

I’m unclear on the get_the_foo() style of functions, for example get_the_permalink().

My main question is: when this is performed in The Loop, is another SQL query executed (besides the original WP_Query())?

But: if performed by itself, e.g. get_the_permalink($someId), a query is executed, correct?

2 Answers
2

Query results for posts, terms, and metadata get placed in cache. If a function is called that accesses data from previously queried objects within the same request (or you’re using a persistent cache mechanism that maintains data across requests), it will not trigger another query and will instead fetch the data from cache.

Leave a Comment