Using is_main_query()


is_main_query() is a new function as of ver 3.3 that allows us to target the main loop on the page, which is useful if there are several custom loops running on a page.

One basic example of its usage is for adding on to the_content filter, appending something before or after content, such as a like button or some custom text. is_main_query() ensures your addition only appears in the main query, as opposed to on each query running on the page.

Pippin Williamson does a great job of explaining its usage. I’ll leave it to him.