Skip to content

Instantly share code, notes, and snippets.

@1-800-jono
Last active March 26, 2018 16:58
Show Gist options
  • Save 1-800-jono/8677752d17371208d02706200d74dda5 to your computer and use it in GitHub Desktop.
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.
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