0
votes

I have added a custom post type with its own categories. When I want to navigate to the taxonomy through the menu, my complete website just crashes. I use the same name for some categories in my custom taxonomy as with my posts, but I don't think this is the problem. Any ideas as to what I might be doing wrong here?

add_action('init', 'ptu_create_post_types');
function ptu_create_post_types() {
    register_taxonomy('hotel-taxonomy', 'hotel',
        array(  'hierarchical'      => true,
                'label'             => 'Destinations',
                'singular_label'    => 'Destination',
                'rewrite'           => array('slug' => 'hotels', 'with_front' => false),
                'public'            => true,
                'show_ui'           => true,
                'show_tagcloud'     => true,
                '_builtin'          => true,
                'show_in_nav_menus' => true));

    register_post_type('hotel', 
        array('labels'              => array(
            'name'                  => __('Hotels'),
            'singular_name'         => __('Hotel'),
            'add_new'               => __('Add new hotel'),
            'edit_item'             => __('Edit hotel'),
            'new_item'              => __('New hotel'),
            'view_item'             => __('View hotel'),
            'search_items'          => __('Search hotels'),
            'not_found'             => __('No hotels found'),
            'not_found_in_trash'    => __('No hotels found in trash')),

            'public'                => true,
            'supports'              => array('title', 'editor', 'post-formats')
    ));
}
1
There is something else going on. I just tested this exact code and it worked fine. Including using the same name and slug for a destination as for a normal post category. Is there anything in your error logs? - Austin Winstanley
I tested/debugged everything over and over and finally found that it was not in fact this piece of code that was broken, but a custom excerpt function that got stuck in a while-loop for some reason (it only happens on the custom taxonomies). The error logs didn't show anything though, so by the time I figured out what was going on ... - Michiel Standaert

1 Answers

0
votes

I tested/debugged everything over and over and finally found that it was not in fact this piece of code that was broken, but a custom excerpt function that got stuck in a while-loop for some reason (it only happens on the custom taxonomies). The error logs didn't show anything though, so by the time I figured out what was going on ...