I'm writing my own WordPress theme and I'm having problems with the archive page. My archive link yields a 404 Not Found. I get this link from get_post_type_archive_link("post") and it just adds /archives to the base URL of my website.

My permalink structure is set to Post name and I have clicked Save changes to make sure that any pending .htaccess changes were saved. Category links work fine. Here's a list of PHP files in my theme root:

  • 404.php
  • front-page.php
  • functions.php
  • index.php
  • pagebottom.php
  • pagetop.php
  • single.php
  • taxonomy.php

Any idea why the archive link isn't working?


I had the same problem: the template hierarchy is not serving up the right file from the hierarchy (at least it should serve index.php if there is no archive.php), but instead it gives a 404.

My solution is to go to the wp-admin interface, select settings>permalinks and change the common settings to some other permalink setting (I changed it from "post name" to "day and name"). Now try again and it should work. Afterwards you can change the settings back to where they were (in my case: "post name") and it will still work, no 404.


Please have a look at WordPress Template Hierarchy here.. For your problem with Archive page you need to create Archive.php file in the theme root. If you want to create separate Archive page for different custom post type then just add post-type name prefix in archive.php file. Example product-archive.php Here is small example for archive page.

File name:- archive.php


/* Template Name: Archives */ get_header(); ?>

    <?php the_post(); ?>
    <h1 class="entry-title"><?php the_title(); ?></h1>

    <?php get_search_form(); ?>

    <h2>Archives by Month:</h2>
        <?php wp_get_archives('type=monthly'); ?>

    <h2>Archives by Subject:</h2>
         <?php wp_list_categories(); ?>

</div><!-- #content -->

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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