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:
/* Template Name: Custom Post Type Landing Page */
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_footer(). Paste this into your template-customposttype.php file, just under the
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!