Skip to content

Instantly share code, notes, and snippets.

@johnjullies
Created July 17, 2019 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnjullies/1b8a0c9dd37388db2918ee89b2db25ae to your computer and use it in GitHub Desktop.
Save johnjullies/1b8a0c9dd37388db2918ee89b2db25ae to your computer and use it in GitHub Desktop.
WordPress: Add custom post type to homepage
function add_custom_pt( $query ) {
if ( !is_admin() && $query->is_main_query() ) {
$query->set( 'post_type', array( 'post', 'the_custom_pt' ) );
}
}
add_action( 'pre_get_posts', 'add_custom_pt' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment