This is not your code I suspect, as there are really many errors in your code. I’m going to list them
Firstly, you are registering your custom post type inside a function that you hook to init
, which is fine. Then you register your taxonomies outside that function. What the reason bhin that is, I don’t know. You should register both your taxonomies and custom post type inside your function, as your taxonomies are registered to your custom post type
Secondly, register_taxonomy( $taxonomy, $object_type, $args );
looks like this. The $object_type
parameter, although taking an array or a string can just be a string, as you are only registering your taxonomy to one custom post type
Thirdly, in the event_cat
taxonomy, this line 'labels' => array(
is missing, breaking everything
Fourthly, in the event_tag
taxonomy, there is this piece this */
of nothingness, which also breaks your code
Lastly, if this was your code, you should have not registered category and tags. Here is the code that registered categories and tags
register_taxonomy_for_object_type('category', 'event_type');
register_taxonomy_for_object_type('post_tag', 'event_type');
So, after all of this, your code should be
function event_post_example() {
register_post_type( 'event_type',
array(
'labels' => array(
'name' => __('Events Posts', 'baretheme'),
'singular_name' => __('Event Post', 'baretheme'),
'all_items' => __('All Event Posts', 'baretheme'),
'add_new' => __('Add New Event Post', 'baretheme'),
'add_new_item' => __('Add New Event Type', 'baretheme'),
'edit' => __( 'Edit', 'baretheme' ),
'edit_item' => __('Edit Post Types', 'baretheme'),
'new_item' => __('New Post Type', 'baretheme'),
'view_item' => __('View Post Type', 'baretheme'),
'search_items' => __('Search Post Type', 'baretheme'),
'not_found' => __('Nothing found in the Database.', 'baretheme'),
'not_found_in_trash' => __('Nothing found in Trash', 'baretheme'),
'parent_item_colon' => ''
), /* end of arrays */
'description' => __( 'This is the example event post type', 'baretheme' ), /* Custom Type Description */
'public' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'show_ui' => true,
'query_var' => true,
'menu_position' => 9,
'menu_icon' => get_stylesheet_directory_uri() . '/library/images/custom-post-icon.png',
'rewrite' => array( 'slug' => 'event_type', 'with_front' => false ),
'has_archive' => 'event_type',
'capability_type' => 'post',
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'sticky')
) /* end of options */
); /* end of register post type */
register_taxonomy( 'event_cat','event_type',
array(
'labels' => array(
'name' => __( 'Event Categories', 'baretheme' ),
'singular_name' => __( 'Event Category', 'baretheme' ),
'search_items' => __( 'Search Event Categories', 'baretheme' ),
'all_items' => __( 'All Event Categories', 'baretheme' ),
'parent_item' => __( 'Parent Event Category', 'baretheme' ),
'parent_item_colon' => __( 'Parent Event Category:', 'baretheme' ),
'edit_item' => __( 'Edit Event Category', 'baretheme' ),
'update_item' => __( 'Update Event Category', 'baretheme' ),
'add_new_item' => __( 'Add New Event Category', 'baretheme' ),
'new_item_name' => __( 'New Event Category Name', 'baretheme' )
),
'hierarchical' => true,
'show_admin_column' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'event-slug' ),
)
);
register_taxonomy( 'event_tag','event_type',
array(
'labels' => array(
'name' => __( 'Event Tags', 'baretheme' ),
'singular_name' => __( 'Event Tag', 'baretheme' ),
'search_items' => __( 'Search Event Tags', 'baretheme' ),
'all_items' => __( 'All Event Tags', 'baretheme' ),
'parent_item' => __( 'Parent Event Tag', 'baretheme' ),
'parent_item_colon' => __( 'Parent Event Tag:', 'baretheme' ),
'edit_item' => __( 'Edit Event Tag', 'baretheme' ),
'update_item' => __( 'Update Event Tag', 'baretheme' ),
'add_new_item' => __( 'Add New Event Tag', 'baretheme' ),
'new_item_name' => __( 'New Event Tag Name', 'baretheme' )
),
'hierarchical' => false,
'show_admin_column' => true,
'show_ui' => true,
'query_var' => true,
)
);
}
add_action( 'init', 'event_post_example');