I found my problem, because I’s causing the issue by myself unknowingly. I’m posting the answer for you to debug if something like this can cause the issue:
I’s using the following code to include all the CPT entries to the default loop. And that’s causing the issue. It’s directing the posttype archive to default post
archive (archive.php
).
<?php
/**
* Adding the Book entries to the loop.
* @param object $query WordPress' default query object.
* ------------------------------------------------------------------------------
*/
function project_add_book_entries_to_query( $query ) {
if ( $query->is_main_query() && !is_admin() ) {
$query->set( 'post_type', array('post', 'books') );
}
}
add_action( 'pre_get_posts', 'project_add_book_entries_to_query' );