Developing my first custom theme and I started out using an individual page-$slug.php to display a list of each custom post. Have since learned that archive.php is better for this purpose (but I just want to use one if possible).

So in admin I've changed the links to the 'post type archive' instead of the page I'd created, and set has_archive to true for each cpt.

But the link now takes me to index.php

My archive.php so far is just this:


if (have_posts()):
    while (have_posts()): the_post();


How do I get it do use the archive.php template and output just the posts of the requested type?

Thanks in advance!


Permalinks are set to 'post type'

Here's the code for 'resource'

register_post_type('resource', array(
        'public' => true,
        'has_archive' => true,
        'taxonomies'  => array(
        'supports' => array(
        'labels' => array(
            'name' => 'Resources',
            'add_new_item' => 'Add New Resource',
            'edit_item' => 'Edit Resource',
            'all_items' => 'All Resources',
            'singular_name' => 'Resource')

and a URL for the archive link is http://youth-cafe.local/resource/

  • 1
    Are permalinks turned on? What does Query Monitor say in the template hierarchy section? Can you give us an example of a URL and post type?
    – Tom J Nowell
    Commented Apr 3, 2019 at 13:07
  • Thanks Pratik, however it seems to have started working..... it's suddenly going to archive.php. This may be something to do with Flywheel(?), this has happened previously where changes don't register immediately. I tried rebooting a couple of times but nothing happened until now. I'll add the requested examples anyway.
    – JakePowell
    Commented Apr 3, 2019 at 13:21
  • 2
    Sounds like you're dealing with caching of some sort
    – Tom J Nowell
    Commented Apr 3, 2019 at 13:52
  • 1
    You can disable caching on Flywheel by turning on Development Mode under the Advanced tab. Commented Apr 3, 2019 at 15:05

1 Answer 1


Hello I had same problem, are you using front-page.php or home.php?

In my case problem was in front-page.php, wp is indexing front-page for homepage and not index.php.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.