Last active
December 14, 2015 05:59
-
-
Save alwerner/5039231 to your computer and use it in GitHub Desktop.
Display Wordpress Custom Post Types on home page, add to functions.php
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
// Display Custom Post Types on home page, add to functions.php | |
add_filter( 'pre_get_posts', 'my_get_posts' ); | |
function my_get_posts( $query ) { | |
if ( is_home() && $query->is_main_query() ) | |
$query->set( 'post_type', array( 'news' ) ); //add cpt, in this case 'news' to array | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment