[wp-hackers] how to check if current loop is main loop?

Christopher Ross cross at thisismyurl.com
Sat May 28 19:28:02 UTC 2011


I assume this is in your own theme, if it is I would recommend adding it to the loop.php or individual cases as a special case.

if (!isset($firstcount)) {$firstcount++; custom_function();}

(not tested)


On 2011-05-28, at 3:59 PM, Konrad Karpieszuk wrote:

> hello
> i want to add smth before first post on the page. i am thinking about
> action hack loop_start, is it a right direction?
> but i want to add this smth only in main loop. if it is homepage (or
> any archive page), only before first post in main loop. if it is
> single post, only before first post.
> because theme developers usually put in theme many special loops (for
> example loop for featured posts, used in some sliders etc) i want to
> avoid to run my function in this special loop. how can i check (inside
> the function) if loop_start is fired in context of main loop for
> particular page?
> -- 
> (en) regards / (pl) pozdrawiam
> Konrad Karpieszuk
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


Christopher Ross

Toronto - (416) 900-3731

More information about the wp-hackers mailing list