How to Create Custom Post Type Archive Page

As you might know, a regular WordPress archive page contains ordinary content types. So a custom post type archive page will list all of your custom post types.

There’s no need to say how fantastic it is to have an archive page on your site. It not only helps to navigate you and even your users to the desired content easily but also benefits search engine presence as well.

However, creating an archive page for custom post types differs a little bit from creating a standard archive page. In this article, you will learn how to create a custom post type archive page on your WordPress site effectively by using code and plugins.

How to Manually Create CPT Archive Page

3 Plugins to Customize CPT Archive Page

Final Thoughts

How to Create a Custom Post Type Archive Page Manually

The very first thing you need to check is whether the archive has been enabled in your custom post type yet.

If not, let’s find your custom post type code which is either in your theme’s function.php file or a site-specific plugin. Now you should have your has_archive argument set true.

This is how your code will look like

add_action( ‘init’, ‘create_post_type’ );

function create_post_type() {

    register_post_type( ‘Example’,

        array(

            ‘labels’ => array(

                ‘name’ => __( ‘Example’ ),

                ‘singular_name’ => __( ‘Example’ )

            ),

        ‘public’ => true,

        ‘has_archive’ => true,

        )

    );

}

Normally, this custom post type archive page will display according to the archive template of your current theme. If you like the default template of your archive page, you’re pretty much done with creating an archive page for your custom post type.

However, the default design of WordPress, which is too simple and not attractive, makes it unable to deliver the full purpose of an archive page.

That’s why you should create a custom archive page. First thing first, create a new file called archive-{posttype}.php. The {posttype} is your archive name, for our above example, it’s archive-example.php.

After that, copy the code from your theme’s archive.php file and paste it in your new archive file. Now you are free to customize it as whatever you want. Here is the example of a basic template:

<?php

get_header();

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

    the_title();

    echo ‘<div class=”entry-content”>’;

    the_content();

    echo ‘</div>’;

endwhile; endif;

get_footer();

?>

You should see a new archive page that contains all important custom post types on your WordPress site.

This method is only easy to follow if you’re a developer or familiar with coding. Or else, you probably find it too complicated, and afraid of messing up your whole theme function. This is when plugins come in handy.

3 Best Plugins for Custom Post Type Archive Page

Lucky for us, WordPress provides several archive page support plugins on its repository. The following are the best 3 plugins for handling a custom post type archive page that you should try.

1. Annual Archive

Annual Archive

This is so far the most famous one for the archive page among the introduced plugins. It has been getting more than 10,000 active installations from WordPress users.

Annual Archive is an efficient plugin that allows you to list your posts and pages by day, week, month, year, or posts by posts, and even alphabetically.

The Annual Archive Pro which costs around $23 will let you list archives by custom post types and categories. With the Pro version, you can customize date formats for your archive page as well.

2. Custom Post Type Date Archive

Custom post type date archives

This user-friendly plugin adds date archives to custom post types right in the dashboard for your convenience. It displays archives, calendar, and recent posts by widgets and editor blocks.

In order to view date archives of custom post types in a permalink, the plugin adds rewrite rules. Especially with custom post type date archives, users can apply some available extra template files and template functions.

3. Archive Control

archive control

This plugin provides “a quick, easy way to customize archive pages.” Inside the archives list, you can add editable content before and after creating.

Plus, Archive Control helps you add a featured image to the archive page. Normally, the feature image will be added automatically above the list, but you can adjust this based on your theme function.

For categories, tags, or custom taxonomies, you are able to customize the order, hide the term description field, or hide the parent field within the WordPress backend.

Remember that this plugin cannot help you with displaying the archive page in the front end. You might need to do the design by yourself or consider other plugins.

Final Thoughts

Back then, the archive page didn’t get a lot of attention from WordPress website owners. If you tried to find a plugin for the archive page five years ago, you would be disappointed with the number of available plugins.

And even though plenty of modern themes come with an archive.php template, some of them don’t support the archive page for custom post types.

Using code to add an archive page for custom post types is one of the most cost-effective solutions. You don’t have to pay for a plugin, but you may spend a little more time doing it. Also, designing the archive page manually is often more complicated and you might go through a lot of failed trials to get good final results.

Fortunately, the recommended three plugins above can save you. For example, if you want to create a custom post type archive page to introduce your employees, you don’t want it to look so plain and boring. Archive Control plugin lets you design, and add featured images to that archive page effectively.

Or you also have Custom Post Type Date Archive and Annual Archive plugins to help you customize the archive page as a calendar or event box to display your desired posts with ease.

Leave your thoughts in the comment section below to let us know what you think about archive page creation. Don’t forget to install Password Protect WordPress to protect your custom post types now.