How to Create a Custom Post Types Archive Page in WordPress (2023)
Are you using custom post types on your WordPress site? If so, you‘ll definitely want to set up engaging archive pages to display those custom post type items.
Archive pages make it easy for visitors to browse all content within a specific post type. With a well-designed custom post type archive, you can deliver an excellent user experience while boosting your SEO.
In this guide, we‘ll walk you through everything you need to know to create attractive, effective custom post type archives in WordPress. Let‘s dive in!
What Are Custom Post Types in WordPress?
Before we talk about archive pages, let‘s make sure we‘re on the same page about custom post types.
In WordPress, post types are content types that share similar characteristics. By default, WordPress comes with two main post types:
- Posts – These are blog posts displayed in reverse chronological order.
- Pages – These are static pages not associated with a publish date.
WordPress also has other built-in post types like attachments, revisions, and navigation menus. And some WordPress plugins register their own custom post types.
For example, if you use WooCommerce to run an online store, it will add a Products post type to manage your product listings. Similarly, many directory plugins create a custom post type for the directory listings.
You can also create your own custom post types for content that doesn‘t fit neatly into a standard post or page. Here are some examples of content you might want to use a custom post type for:
- Portfolio projects
- Real estate listings
- Courses
- Recipes
- Events
- Job postings
- Staff/team members
- Testimonials
Using a custom post type lets you customize the editing experience and display those items differently than your regular posts and pages.
What Is an Archive Page in WordPress?
An archive page in WordPress displays a list of content. The default archives in WordPress include:
- Blog post archives by month, year, or category
- Author archives showing posts by a single author
- Search results pages
- Tag archives listing posts with a certain tag
Custom post types can have archive pages too. When you register a custom post type, you have the option to enable archives.
With archives enabled, all content published under that custom post type will automatically have an archive page created. This lets users view a list of all items within that post type.
For example, let‘s say you created a custom post type called "Projects" for your portfolio. With archives enabled, WordPress would generate a Projects archive page showing all your portfolio projects.
The URL for this page would typically be something like:
Why Use Custom Post Type Archives?
It‘s a best practice to create useful archive pages for your custom post types. Here‘s why:
Better user experience – Archive pages help visitors find the exact content they‘re looking for. They can easily see all items in a specific content type.
Improved navigation – You can link to custom post type archives in your navigation menus. This helps users move through your site and discover key content.
Increased pageviews – When users land on an archive page, they‘ll often click through to view individual items in the list. This boosts your pageviews and engagement.
SEO benefits – Search engines like Google appreciate when websites are well-organized and easy to navigate. Having dedicated pages for your most important content categories may give you an SEO advantage. Plus, you can optimize your archive pages to rank for relevant keywords.
Now that you know why custom post type archives are so valuable, let‘s look at how to set them up on your WordPress site.
How to Enable Custom Post Type Archives
First, navigate to where your custom post type is defined. Depending on how you created your custom post type, this will either be:
- In the plugin settings, if you used a plugin
- In your theme‘s functions.php file
- In a site-specific plugin
If you used a plugin like Custom Post Type UI or Pods, you can simply edit the post type and check the box for "Has Archive."
If you registered the post type manually in your theme or plugin, look for the arguments section in the register_post_type function.
Make sure ‘has_archive‘ is set to true, like this:
‘has_archive‘ => trueSee the WordPress documentation for a full explanation of register_post_type and the available arguments.
Once archives are enabled, you should be able to view the archive page for your custom post type.
Go to https://yoursite.com/post-type-slug. If you see a list of items in that post type, then the archive is working.
If you get a 404 error, double check that you‘ve enabled archives correctly.
Creating a Custom Archive Page Template
By default, your theme will use the built-in archive.php template to display custom post type archives. But you‘ll probably want to customize the look and layout of your archive page.
To do that, you can create a custom archive template. Here‘s how:
- In your WordPress theme folder, find the existing archive.php file.
- Copy the archive.php file and rename it to archive-{post_type}.php, replacing {post_type} with the name of your custom post type. For example, archive-project.php.
- Edit the new file you created to customize the HTML structure and add your own styles.
You can use standard WordPress template tags to display information about the items in your archive. Some useful template tags include:
- the_title() – displays the title of the post
- the_excerpt() – displays a short excerpt from the post content
- the_permalink() – the URL of the individual post
- the_post_thumbnail() – displays the featured image
For example, here‘s a simple loop that displays each item in the archive:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php the_title( ‘<h2><a href="‘ . esc_url( get_permalink() ) . ‘">‘, ‘</a></h2>‘ ); ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<?php the_excerpt(); ?>
</article>
<?php endwhile; endif; ?>Feel free to customize this loop to fit your needs. You can add custom fields, change the styling, and include whatever other content you‘d like.
When you‘re finished, save the file and upload it to your theme directory. Now WordPress will use your custom template to display the archive page for that post type.
Using a Page Builder for Custom Post Type Archives
If you‘re not comfortable editing template files directly, there‘s an easier solution. You can use a page builder plugin to design your custom post type archive.
We recommend SeedProd, the best drag-and-drop page builder for WordPress. It lets you create custom page layouts without any code.
To use SeedProd for your post type archive:
- Install and activate the SeedProd plugin.
- From the SeedProd dashboard, click the Add New Landing Page button.
- Choose a template for your archive page and click the Setup Guide button.
- On the setup page, enter a name and URL for your archive page. The URL should be the same as your post type‘s built-in archive page.
- Customize the content, layout, and styling of your archive page using the visual editor.
- Under the Page Settings, set the status to Published.
- Click Save and your custom archive page will be live.
The SeedProd Post Grid block is perfect for displaying posts from your custom post type. You can customize exactly which fields to display, how many posts to show, and what order to display them in.
This is a great option for users who want complete control over their archive layout and styling without editing theme files.
Examples of Custom Post Type Archive Pages
Need some inspiration for your own custom post type archives? Here are a few examples to spark your creativity:
WPBeginner Deals – This archive page displays a list of current deals and special offers. It uses a clean grid layout to showcase each deal.
Visit London Events – The official tourism site for London has a well-organized events archive. Users can filter events by date, category, and location.
The White House Press Briefings – This archive page shows a reverse chronological list of all press briefings. It‘s easy to scan the titles to find specific briefings.
charity: water Completed Projects – This attractive archive page showcases the water projects charity: water has completed around the world.
Spotify Newsroom – Spotify uses a custom post type for their press releases and displays them in this sleek newsroom archive.
Think about what type of content you‘re featuring in your archives and what actions you want users to take. Let that guide your layout and design decisions.
Bonus Tips for Custom Post Type Archives
Here are a few more tips to take your custom post type archives to the next level:
Customize the Number of Posts Displayed
By default, WordPress will display 10 posts per page on your archive. If you want to change that number, you can add this line to your archive template file:
query_posts(‘posts_per_page=5‘);Replace 5 with the number of posts you want to show per page.
Add Filtering and Sorting Options
If you have a lot of posts in your archive, consider adding ways for users to filter and sort the list. This could be by date, category, tag, or any other taxonomy.
The Jetpack plugin includes a custom content type filtering module that makes this easy.
Use Featured Images
Make sure to set featured images for all posts in your custom post type. You can display these thumbnails on the archive page to add visual interest and make it easier for users to find the post they‘re looking for.
Customize the Archive Title and Description
You can use the the_archive_title() and the_archive_description() template tags to display a title and description at the top of your archive page.
Customize these to make it crystal clear to users what content they‘ll find on the page. You might include a call-to-action or links to related content.
Cross-Link to Related Content
Think about how your custom post type archive fits in with the rest of your site. Include links to related posts, pages, or even other custom post type archives.
This will help users discover more of your content and keep them engaged on your site longer.
Optimize for Search Engines
Finally, make sure your archive pages are optimized for search engines:
- Use a descriptive page title that includes your target keywords
- Write a compelling meta description
- Use header tags (H1, H2, etc.) to structure your page content
- Include internal links to and from your archive pages
- Add schema markup if appropriate
By following SEO best practices, you‘ll make your archive pages more likely to rank well in search results and drive organic traffic to your site.
Conclusion
Custom post type archives are an essential part of any WordPress site that uses custom content types. With the tips and techniques in this guide, you‘re ready to create your own engaging, user-friendly archive pages.
Remember, the key is to design your archives with your unique content and audience in mind. Think about what will be most helpful for your users and how you can best showcase your awesome content.
If you get stuck, don‘t hesitate to reach out for help. The WordPress community is full of generous developers who are happy to lend a hand.
Now go forth and create some amazing archives!
