mardi 24 mars 2015

Page Template as Custom Post Type Archive


My goal is to have the slug http://ift.tt/1FRtmG4 used by a Page Template rather than an Archive Page, and have single CPT posts as children of that slug, such as http://ift.tt/1EJCcE8.


Solution I thought would work:


I created a new Page in Wordpress and gave it a custom page template. I'm also registering my custom post type as follows. Pay special attention to has_archive and rewrite:



function bb_resources() {
register_post_type( 'resources', array(
'labels' => array(
'name' => 'Resources',
'singular_name' => 'Resource',
),
'taxonomies' => array('resources_cat'),
'public' => true,
'has_archive' => false,
'show_ui' => true,
'supports' => array( 'title', 'editor' ),
'rewrite' => array('slug'=>'resources', 'with_front'=>false),
) );
}


This, however, creates a 404 on the single post pages.


I'm stumped, please advise!





Aucun commentaire:

Enregistrer un commentaire