I basically have the same problem like in this question, but the correct answer doesn't work for me. Yes, I get a list of posts from my CPT, but the archive-{post-type}.php
is not used to render the page. It still uses the index.php
. Any help would be great!
This is my code:
add_action('pre_get_posts', 'my_front_page');
function my_front_page($wp_query) {
$post_type = 'foobar';
if ( $wp_query->get('page_id') == get_option('page_on_front') ) {
$wp_query->set('post_type', $post_type);
$wp_query->set('page_id', '');
// Fix conditional functions like is_front_page or is_single
$wp_query->is_page = 0;
$wp_query->is_singular = 0;
}
}