[wp-trac] [WordPress Trac] #16233: Custom taxonomy archive returns 404 when it contains only custom post types

WordPress Trac wp-trac at lists.automattic.com
Fri Jan 14 17:11:38 UTC 2011


#16233: Custom taxonomy archive returns 404 when it contains only custom post types
--------------------------+------------------------------
 Reporter:  sillybean     |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Taxonomy      |     Version:  3.1
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+------------------------------

Old description:

> I'm working with a few custom taxonomies that are registered only for a
> custom post type, not posts or pages. The archive pages return 404s
> unless I add posts or pages to the taxonomy's content object argument.
>
> Here's the post type:
> `
> register_post_type(
>         'course',
>         array(
>                 'labels' => array(
>                 'name' => __( 'Courses' ),
>                 'singular_name' => __( 'Course' ),
>                 'add_new' => __('Add New'),
>                 'add_new_item' => __('Add New Course'),
>                 'edit_item' => __('Edit Course'),
>                 'new_item' => __('New Course'),
>                 'view_item' => __('View Course'),
>                 'search_items' => __('Search Courses'),
>                 'not_found' => __('No courses found'),
>                 'not_found_in_trash' => __('No courses found in Trash'),
>                 'menu_name' => __('Courses'),
>         ),
>         'capability_type' => 'post',
>         'map_meta_cap' => true,
>         'capabilities' => array(
>                 'edit_post' => 'edit_course',
>                 'read_post' => 'read_course',
>                 'delete_post' => 'delete_course',
>         ),
>         'description' => __('Individual course data'),
>         'public' => true,
>         'show_ui' => true,
>         'hierarchical' => false,
>         'menu_icon' => get_bloginfo('template_url').'/images/bank.png',
>         'register_meta_box_cb' => 'course_meta_boxes',
>         'supports' => array(
>         'title',
>         'editor',
>         'author',
>         'excerpt',
>         'custom-fields',
>         'revisions',)
>         )
> );
> `
>
> And one of the taxonomies:
>
> `
> register_taxonomy(
>         'college',
>         'course',
>         array(
>                 'labels' => array(
>                 'name' => __( 'Colleges' ),
>                 'singular_name' => __( 'College' ),
>                 'search_items' => __( 'Search Colleges' ),
>                 'popular_items' => __( 'Popular Colleges' ),
>                 'all_items' => __( 'All Colleges' ),
>                 'parent_item' => __( 'Parent College' ),
>                 'parent_item_colon' => __( 'Parent College:' ),
>                 'edit_item' => __( 'Edit College' ),
>                 'update_item' => __( 'Update College' ),
>                 'add_new_item' => __( 'Add New College' ),
>                 'new_item_name' => __( 'New College Name' ),
>                 'separate_items_with_commas' => __( 'Separate colleges
> with commas' ),
>                 'add_or_remove_items' => __( 'Add or remove colleges' ),
>                 'choose_from_most_used' => __( 'Choose from the most used
> colleges' ),
>                 'menu_name' => __('Colleges'),
>         ),
>         'hierarchical' => true,
>         )
> );
> `
>
> Create a few courses, assign them to colleges, and the archives (e.g.
> /college/liberal-arts) don't work.
>
> If I change the taxonomy definition to include posts (or pages), the
> archive suddenly work.
>
> `
> register_taxonomy(
>         'college',
>         'course',
>         array(
>                 'labels' => array(),
>         'hierarchical' => true,
>         )
> );
> `

New description:

 I'm working with a few custom taxonomies that are registered only for a
 custom post type, not posts or pages. The archive pages return 404s unless
 I add posts or pages to the taxonomy's content object argument.

 Here's the post type:
 {{{
 register_post_type(
         'course',
         array(
                 'labels' => array(
                 'name' => __( 'Courses' ),
                 'singular_name' => __( 'Course' ),
                 'add_new' => __('Add New'),
                 'add_new_item' => __('Add New Course'),
                 'edit_item' => __('Edit Course'),
                 'new_item' => __('New Course'),
                 'view_item' => __('View Course'),
                 'search_items' => __('Search Courses'),
                 'not_found' => __('No courses found'),
                 'not_found_in_trash' => __('No courses found in Trash'),
                 'menu_name' => __('Courses'),
         ),
         'capability_type' => 'post',
         'map_meta_cap' => true,
         'capabilities' => array(
                 'edit_post' => 'edit_course',
                 'read_post' => 'read_course',
                 'delete_post' => 'delete_course',
         ),
         'description' => __('Individual course data'),
         'public' => true,
         'show_ui' => true,
         'hierarchical' => false,
         'menu_icon' => get_bloginfo('template_url').'/images/bank.png',
         'register_meta_box_cb' => 'course_meta_boxes',
         'supports' => array(
         'title',
         'editor',
         'author',
         'excerpt',
         'custom-fields',
         'revisions',)
         )
 );
 }}}

 And one of the taxonomies:

 {{{
 register_taxonomy(
         'college',
         'course',
         array(
                 'labels' => array(
                 'name' => __( 'Colleges' ),
                 'singular_name' => __( 'College' ),
                 'search_items' => __( 'Search Colleges' ),
                 'popular_items' => __( 'Popular Colleges' ),
                 'all_items' => __( 'All Colleges' ),
                 'parent_item' => __( 'Parent College' ),
                 'parent_item_colon' => __( 'Parent College:' ),
                 'edit_item' => __( 'Edit College' ),
                 'update_item' => __( 'Update College' ),
                 'add_new_item' => __( 'Add New College' ),
                 'new_item_name' => __( 'New College Name' ),
                 'separate_items_with_commas' => __( 'Separate colleges
 with commas' ),
                 'add_or_remove_items' => __( 'Add or remove colleges' ),
                 'choose_from_most_used' => __( 'Choose from the most used
 colleges' ),
                 'menu_name' => __('Colleges'),
         ),
         'hierarchical' => true,
         )
 );
 }}}

 Create a few courses, assign them to colleges, and the archives (e.g.
 /college/liberal-arts) don't work.

 If I change the taxonomy definition to include posts (or pages), the
 archive suddenly work.

 {{{
 register_taxonomy(
         'college',
         'course',
         array(
                 'labels' => array(),
         'hierarchical' => true,
         )
 );
 }}}

--

Comment (by dd32):

 Just updating the ticket formatting.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16233#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list