Last active
March 26, 2018 16:58
-
-
Save 1-800-jono/8677752d17371208d02706200d74dda5 to your computer and use it in GitHub Desktop.
WordPress: Add extra post types to main WP post loop. Add this code to functions.php file.
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
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( 'post', 'custom_post_name' ) ); | |
$query->set( 'order', 'ASC'); | |
$query->set( 'posts_per_page', 3); | |
} | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment