0

I have created a custom post type "Events" and added the categories function for it. However, the categories only shows in the backend CMS which I can set and add new categories, but no message indicating the category that a event was set for in the front end webpage.

How can I make the events categories information shown in the front end webpage?

I have copied the code below:

function enable_event_posttype() {
    register_post_type( 'events',
        array(
            'labels' => array(
                'name' => __( 'Events' ),
                'singular_name' => __( 'Event' ),
                'add_new' => __( 'Add New Event' ),
                'add_new_item' => __( 'Add New Event' ),
                'edit_item' => __( 'Edit Event' ),
                'new_item' => __( 'Add New Event' ),
                'view_item' => __( 'View Event' ),
                'search_items' => __( 'Search Event' ),
                'not_found' => __( 'No events found' ),
                'not_found_in_trash' => __( 'No events found in trash' )
            ),
            'public' => true,

                'supports' => array( 'title', 'editor', 'comments'),
            'capability_type' => 'post',
            'rewrite' => array("slug" => "events"), // Permalinks format
            'menu_icon' => get_bloginfo('stylesheet_directory') . '/images/date.png',  // Icon Path
            'menu_position' => '5'
        )
    );
}

add_action( 'init', 'enable_event_posttype' );



add_action( 'init', 'build_taxonomies', 0 );

function build_taxonomies() {
  register_taxonomy( 'categories', 'events', array( 'hierarchical' => true,  'label' => 'Categories', 'query_var' => true, 'rewrite' => true ) );
}

1 Answer 1

0

It seems like you got a permalink conflict. You can't give two "things" the same slug/URi in WordPress. Please try it with a different slug than events either for the custom post type or the custom taxonomy.

And yes, I know, this answer will be flagged as "low quality" due to its length.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.