Created
May 20, 2013 15:41
-
-
Save jlittlejohn/5613047 to your computer and use it in GitHub Desktop.
WP: pre_get_posts Filter
This file contains hidden or 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
// Use as an alternative to query_posts. note: doesn't work for pages | |
add_action('pre_get_posts','wpse50761_alter_query'); | |
function wpse50761_alter_query($query){ | |
if( $query->is_main_query() ){ | |
//Do something to main query | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment