If I use pre_get_posts
this way
function ef_company_query($query) {
if ( !is_admin() && $query->is_main_query() && $query->is_post_type_archive( 'company' ) ) {
$query->set('post_type', array( 'company', 'mission', 'values', 'staff' ) );
}
}
add_action('pre_get_posts','ef_company_query');
it seems that wordpress won't load archive-company.php but archive.php.
How should I use pre_get_posts
to append extra CPTs to an archive page?
EDIT 1
I mentioned archive-company.php because I want to load the extra CPTs at URL www.website.com/company.
EDIT 2
I'm open to any solution which pulls a specific template based on the URL www.website.com/company and allows the addition of the extra CPTs (preferably via pre_get_posts
, performance wise).
EDIT 3
Trying to make things more clear here!
I want to be able to load several CPTs on the URL www.website.com/company.
- Which template should/can I use?
- How to append the CPTs to the main query (hopefully via
pre_get_posts
, performance wise)?
I'm trying to avoid the use of new WP_Query()
and having multiple loops in the page.