Skip to content

Instantly share code, notes, and snippets.

@alwerner
Last active December 14, 2015 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alwerner/5039231 to your computer and use it in GitHub Desktop.
Save alwerner/5039231 to your computer and use it in GitHub Desktop.
Display Wordpress Custom Post Types on home page, add to functions.php
// 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