Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Using WordPress 3.8 Icons for your Custom Post Types
<?php
function add_menu_icons_styles(){
?>
<style>
#adminmenu .menu-icon-events div.wp-menu-image:before {
content: '\f145';
}
</style>
<?php
}
add_action( 'admin_head', 'add_menu_icons_styles' );
#adminmenu .menu-icon-events div.wp-menu-image:before {
content: '\f145';
}
<?php
function create_events_cpt() {
register_post_type( 'events',
array(
'public' => true,
'has_archive' => true,
'menu_position' => 5, // places menu item directly below Posts
'menu_icon' => '',
'labels' => array(
'name' => __( 'Events' ),
'singular_name' => __( 'Event' ),
'add_new' => __( 'Add New' ),
'add_new_item' => __( 'Add New Event' ),
'edit' => __( 'Edit' ),
'edit_item' => __( 'Edit Event' ),
'new_item' => __( 'New Event' ),
'view' => __( 'View Event' ),
'view_item' => __( 'View Event' ),
'search_items' => __( 'Search Events' ),
'not_found' => __( 'No Events found' ),
'not_found_in_trash' => __( 'No Events found in Trash' ),
'parent' => __( 'Parent Event' ),
),
)
);
}
add_action( 'init', 'create_events_cpt' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment