I have several custom post types and we need to create separate archive templates for these. I tried the following advice, but it’s still using the default archive template.
In the form of the single-type-template. In the same way that posts
are shown on their own page with single.php, custom post types will
use single-{posttype}.php if it’s available.So for the above example, you could create a single-acme_product.php
file and the product posts would be shown using that template.In the form of the archive-type-template. In the same way that posts
are shown on their own archive with archive.php, custom post types
will use archive-{posttype}.php if it’s available.So for the above example, you could create a archive-acme_product.php
file and the product posts would be shown using that template.
Any help would be greatly appreciated.
Here is my code
function camps_register_post_type() {
register_post_type('camps', array(
'labels' => array(
'name' => 'Camps & holidays',
'singular_name' => 'Camps & holidays',
'add_new' => 'Add New Camps & holidays',
'edit_item' => 'Edit Camps & holidays',
'new_item' => 'New Camps & holidays',
'view_item' => 'View Camps & holidays',
'search_items' => 'Search Camps & holidays',
'not_found' => 'No Camps & holidays found',
'not_found_in_trash' => 'No Camps & holidays found in Trash'
),
'public' => true,
'has_archive' => true,
'rewrite' => array("slug" => "camps"), // the slug for permalinks
'supports' => array('title', 'editor', 'thumbnail')
));
}
For custom post type with slug
camps
:single-camps.php
archive-camps.php