[wp-hackers] Knowing when you're in The Loop, and when you're not

Kaf Oseo kaf at szub.net
Fri Jul 15 15:39:31 GMT 2005


I have a copyright mark plugin which bases it's output in part on the
query type, so single posts, Pages and archive queries display the year
for the current content, while elsewhere a range (first-last) is used.
When the plugin function blog_copyright() is called within The Loop, for
query types other than those listed I'd like it to be "Loop aware" and
display the year of the current post, instead of a range.

Testing on $post or something like get_the_author() works to a degree,
but as these leak out beyond The Loop calling the function afterwards
provides false positives. I had luck with have_posts(), but this fails
in the last post of The Loop, and won't work if using a foreach() loop
statement.

I'm about to go the way of a parameter, but before taking such a drastic
measure (...), is there some variable or mechanism I can test on that's
only around while The Loop is in effect?

-Kaf


More information about the wp-hackers mailing list