I'm trying to set up a custom archive template for a custom post type I created in functions.php. Here is the code in functions:
add_action('init', 'create_post_type');
function create_post_type() {
$labels = array(
'name' => __('Portfolio Posts'),
'singular_name' => __('Portfolio Post')
);
$args = array(
'labels' => $labels,
'public' => true,
'has_archive' => true,
'rewrite' => false,
'supports' => array('title', 'editor', 'excerpt'),
'taxonomies' => array('category'),
);
register_post_type('cc-portfolio', $args);
}
I've also created my archive-cc-portfolio.php file.
The problem is, when I access the site http://site.com/cc-portfolio/ I get the default index.php file used as the template.
Any ideas what I am doing wrong or where to start looking?
Thanks,
Phil
Your archive page template will only show when you view a piece of content.
If you add content with title "abcd" and assuming you have permalinks as "%postname%", the you would access that content as
http://site.com/cc-portfolio/abcd .
I also believe that you need to name your template single-cc-portfolio.php
Have a look at the following plugin
http://wordpress.org/extend/plugins/custom-content-type-manager/
Try and play with that, and you'll probably see where you're going wrong :)
Thanks
Blake
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.