Ever wondered how to organize and display collections of specialized content on your WordPress site? That’s exactly what custom post type archive pages do, and I’m going to walk you through creating them in simple, easy to understand language.
Manually creating a custom archive page for a post type
In WordPress, “custom post types” (CPTs) are specialized content formats beyond regular posts and pages. They could be products, team members, testimonials, recipes, portfolio items, or any other unique content type your website needs.
An archive page is simply a collection page that displays multiple items of the same type in one place. Think of your blog page showing all your blog posts – that’s an archive page for standard posts.
Creating archive pages for your custom post types offers three big benefits:
- SEO advantages by grouping related content together
- Better navigation for your visitors
- Improved organization of your content
Creating a Custom Post Type Archive Page: The Manual Method
Step 1: Enable Archives for Your Custom Post Type
Find where your custom post type is registered – usually in your theme’s functions.php file or in a custom plugin. Make sure the has_archive parameter is set to true:
add_action('init', 'create_post_type');
function create_post_type() {
register_post_type('example',
array(
'labels' => array(
'name' => __('Examples'),
'singular_name' => __('Example')
),
'public' => true,
'has_archive' => true, // This enables the archive page
)
);
}
After making this change, don’t forget to refresh your permalinks by going to Settings → Permalinks and clicking “Save Changes.”
Step 2: Create a Custom Template for Your Archive
By default, WordPress will use your theme’s standard archive template for custom post types. If you want something more specialized, you’ll need to create a custom template file.
- Create a new file in your theme folder named
archive-{posttype}.php(replace {posttype} with your actual post type name) - For example, if your custom post type is called “recipes,” create
archive-recipes.php - Start by copying the code from your theme’s existing
archive.phptemplate - Customize the template to display your custom post type content how you want
Here’s a simplified example template:
<?php
get_header();
if (have_posts()) :
echo '<div class="custom-archive-container">';
// Optional: Add a title or description for this archive
echo '<h1 class="archive-title">All Examples</h1>';
while (have_posts()) : the_post();
// Display each post
echo '<article class="archive-item">';
echo '<h2><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>';
the_excerpt();
echo '</article>';
endwhile;
echo '</div>';
// Add pagination if needed
the_posts_pagination();
else :
echo '<p>No examples found</p>';
endif;
get_footer();
?>
This approach gives you complete control, but it does require some coding knowledge. If you’re not comfortable with PHP, the WordPress Block Editor approach below might be better for you.
Modern Approach: Creating CPT Archives with WordPress Block Editor
WordPress has changed dramatically in recent years. While when we originally wrote this article we recommended plugins like Annual Archive and Custom Post Type Date Archive, the truth is that many of these tools have become obsolete.
This is because the Block Editor now provides native functionality for customizing archive pages for custom post types without reaching for plugins. Here’s how to create beautiful archive templates for your custom post types:
1. Enable Full Site Editing in Your Theme
First, make sure you’re using a block-compatible theme. Many newer WordPress themes support Full Site Editing (FSE) by default. You can verify this by checking if you have a “Site Editor” option in your WordPress admin menu.
2. Create a Custom Template for Your Archive
- Go to Appearance → Editor (Site Editor)
- Click on the WordPress logo in the top left corner to open the navigation panel
- Select Templates
- Click the Add New button
- Choose Archive as the template type
- In the dropdown menu, select your specific custom post type archive
- Give your template a name and click Create
3. Design Your Archive Layout
Now, you’re presented with a blank canvas to design your archive page:
- Add a Query Loop block, which is essentially a container that will display your posts
- Configure the Query Loop to display only your specific custom post type
- Choose or create a layout for how each post should display
- Add additional blocks above or below the Query Loop for headings, introductions, or other content
You can customize everything visually:
- Change column layouts
- Add featured images
- Customize typography
- Implement filtering options
- Add pagination styles
- Include custom headers and footers
Once you’re happy with your design, click the Save button in the top right corner. Your custom archive template will now be applied whenever someone visits that custom post type’s archive page.
Conclusion
Creating archive pages for custom post types can be done within WordPress itself through the Block Editor. An alternative that some may choose is the code route as it gives more control, or you can use the Block Editor if you’re looking for a simpler way to customize archive pages for custom post types.