Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin Tadlock justintadlock

View GitHub Profile
@Rarst
Rarst / in_main_query.php
Created Jan 16, 2013
Mark WordPress posts in query if they are in main or secondary.
View in_main_query.php
<?php
add_action( 'loop_start', 'mark_posts_with_query' );
function mark_posts_with_query( $query ) {
$in_main_query = $query->is_main_query();
foreach ( $query->posts as $post ) {