Created
January 30, 2012 15:31
-
-
Save roborourke/1704987 to your computer and use it in GitHub Desktop.
Edit the main WordPress query to show items from a custom post type you specify
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 | |
// replace 'post' with the id of the post type you want for your main listing | |
add_action( 'pre_get_posts', 'modify_main_query' ); | |
function modify_main_query( $query ) { | |
if ( $query !== $wp_the_query || is_admin() ) | |
return $query; | |
$query->query_vars[ 'post_type' ] = 'post'; | |
return $query; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment