On my WordPress website, I have an archive page e.g.: http://www.example.com/2017. My archive.php file has a query to show posts as well as two custom post types: case-studies and media:

global $wp_query;
        $args = array_merge( $wp_query->query, array( 'post_type' => array('post','case-studies','media'), 'posts_per_page' => 3 ) );
        query_posts( $args );

        while ( have_posts() ) : the_post();

The archive page will only show provided there are posts under post (the standard post type that is included within WordPress) otherwise it will 404, even though there are posts under case-studies and media.

Is there a workaround this?

Here is a link to my archive.php for those who are interested: archive.php

Read more here: WordPress: show archive even though there are no posts


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: