On my main page, I want to show posts from 3 categories, and 1 custom post type.
Is there a way to get them together in one pre_get_posts
function? Or do I need to query separately – once for the CPT and once for the posts from specific categories?
If you are after on post from category a, one from category b, another form category c and then finally a custom post type – each of these would have to be a separate query.
Think of these as ‘secondary queries’ – (the primary query being what lands you on the home page). So you’ll want use seperate instances of
WP_Query
(see this related post).E.g.
etc. Don’t forget to call
wp_reset_postdata();
at the end.