Check for the main query from the template
Use in_the_loop(), it returns true if we are in the main loop, false if we are not, like on a custom query loop Return: (bool) True if caller is within loop, false if loop hasn’t started or ended. The difference between is_main_query() and in_the_loop() is that is_main_query() uses WP_Query::is_main_query() which in turn uses the global … Read more