用pre_get_post来调整主页显示的文章类型

function print_recipes_post($query){
	if (!is_admin() && $query->is_main_query()) {
		//add posts to home
		if (is_home()) {
			$query->set('post_type',['post','recipes']);
		}
	}

}
add_action('pre_get_posts','print_recipes_post');
Share :