in_the_loop() WordPress Function
The in_the_loop() function is used to check whether the current code is within a WordPress Loop. If a Loop has not yet started, this function will return false. Otherwise, it will return true. This function can be useful for making sure that certain code is only run when a Loop is active.
in_the_loop() #
Determines whether the caller is in the Loop.
Description
For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.
Return
(bool) True if caller is within loop, false if loop hasn't started or ended.
Source
File: wp-includes/query.php
function in_the_loop() { global $wp_query; return $wp_query->in_the_loop; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |