Created
November 21, 2014 01:45
-
-
Save renventura/bec76f425fed5d8ec20c to your computer and use it in GitHub Desktop.
Show recent custom post types on your blog's home page rather than Posts.
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 //* Mind the opening PHP tag | |
/* | |
* Changes the main query on the home page (blog posts index) to one or more custom post types | |
*/ | |
add_filter( 'pre_get_posts', 'my_custom_query' ); | |
function my_custom_query( $query ) { | |
if ( $query->is_main_query() && $query->is_home() ) { | |
$query->set( 'post_type', array( 'nfl', 'nba', 'mlb', 'nhl', 'ncaaf', 'ncaab' ) ); | |
} | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment