WordPress Tricks: How to create a WYSIWYG page template for an archive page

Recently, I was working on a WordPress site and needed the ability to have editable page content at the top of the archive page for a custom post type.

It took me a bit to figure out how to accomplish it but once I did, I am happy to report the solution was quite simple!

First, clone whichever page template in your theme that you want to use as the base template for your archive page. For example, let’s say you clone page.php and name your new file template-customposttype.php.

Make sure to change or add the template name at the very top of your cloned file:

<?php
/* Template Name: Custom Post Type Landing Page */
 get_header();
?>

Now, under the portion of the template which calls in the page content, let’s add a query for the custom post type we want to display on this page:

<?php query_posts(array('post_type' => 'customposttype')); ?>

Make sure you change ‘customposttype‘ to the actual name of the post type you want to display on this page!

Now, open your theme’s archive.php template file and copy the section between get_header() and get_footer(). Paste this into your template-customposttype.php file, just under the query_posts() statement.

Save your new template.

Now, in the WordPress dashboard, create a new page called My Custom Posts Archive Landing Page. In Page Attributes, make sure to select your new template (“Custom Post Type Landing Page”) to this page.

Add whatever content you want in the visual editor, then publish your new page and view it on your site.

You will now see your custom content at the top of the page and the list of blog posts for your custom post type underneath! Voila!

Meet the author

Libby Fisher is an experienced freelance web developer, recently relocated from Seattle to Boston, and passionate about developing websites that are both aesthetically appealing and intuitively usable - or as she prefers: "beautifully effective."