Created
July 17, 2019 04:58
-
-
Save johnjullies/1b8a0c9dd37388db2918ee89b2db25ae to your computer and use it in GitHub Desktop.
WordPress: Add custom post type to homepage
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
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