When i use the "get_template_part();" inside a loop, does it search for that template file every cycle of the loop (each post) or does it search for the file once and then reuse it every cycle of the loop?
locate_template(), and both functions are running
file_exists() checks for the same file over and over. There is no caching. Meh.
But … PHP has an internal cache for file look-ups, so a direct file access will not happen on every call.
There is an edge case, most developers aren't aware of: A file can be deleted after the first access, and
file_exists() will still return
true if PHP's cache hasn't updated.
That depends entirely on your code. Without seeing any, i will assume you are using a standard WP loop. If so, the template part is included every time the statement is executed. By default that is for every post in the loop.