neilgee
5/8/2015 - 6:50 AM

WordPress Mix Posts and Custom Post Types in the main blog page

WordPress Mix Posts and Custom Post Types in the main blog page

<?

function ng_mix_posts_cpts_in_blog ( $query ) {
	if( !is_admin() && $query->is_main_query() ) {
		if ( $query->is_home()) {
			$query->set('post_type', array('post','yourCPTname'));//swap in your cpt name
		}
	}
}

add_action('pre_get_posts', 'ng_mix_posts_cpts_in_blog' );

//doesnt show for admin, only runs for main query on blog page