[wp-trac] [WordPress Trac] #15239: register_post_type rewrite argument breaks template hierarchy
WordPress Trac
wp-trac at lists.automattic.com
Thu Oct 28 13:02:47 UTC 2010
#15239: register_post_type rewrite argument breaks template hierarchy
--------------------------+-------------------------------------------------
Reporter: croakingtoad | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Post Types | Version: 3.0.1
Severity: normal | Keywords: register_post_type
--------------------------+-------------------------------------------------
I have been working on this issue for days and have discovered, that when
using template hierarchy for custom post types, for example, a CPT of
'sets' would use single-sets.php as a template page. This works fine,
except when the CPT is called 'lego-sets' and you rewrite it to 'sets'
then the template hierarchy "breaks" and WP resorts to single.php or some
other generic file in the template hierarchy.
Doesn't work because of the rewrite with template hierarchy:
{{{
add_action('init','create_post_types');
function create_post_types() {
$sets_labels = array(
'name' => __('LEGO Sets','post
type general name'),
'singular_name' => __('LEGO Set','post type
singular name'),
'add_new' => __('Add New','sets'),
'add_new_item' => __('Add New LEGO Set'),
'edit_item' => __('Edit LEGO Set'),
'new_item' => __('New LEGO Set'),
'view_item' => __('View LEGO Set'),
'search_items' => __('Search LEGO Sets'),
'not_found' => __('No LEGO Sets
found'),
'not_found_in_trash' => __('No LEGO Sets found in Trash'),
'parent_item_colon' => ''
);
$sets_args = array(
'labels' => $sets_labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
// this is the problem line, if you set it to just true or
false it's fine, but if you add the array and slug it breaks
'rewrite' => array('slug' =>
'sets', 'with_front' => false),
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' =>
array('title','editor','author','thumbnail','excerpt','comments')
);
$sets = register_post_type('lego-sets', $sets_args);
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/15239>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list