Created
January 16, 2013 23:08
-
-
Save Rarst/4551879 to your computer and use it in GitHub Desktop.
Mark WordPress posts in query if they are in main or secondary.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ) { | |
$post->in_main_query = $in_main_query; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment