icona custom post

w function.php lub tam gdzie definiujemy custom post type w jego definicji podajemy:


function myTheme_init_posttypes(){

		$event_args = array(
				'labels' => array(
						'name' => 'events',
						'singular_name' => 'event',
						'all_items' => 'All events',
						'add_new' => 'Add new',
						'add_new_item' => 'Add new event',
						'edit_item' => 'Edit event',
						'new_item' => 'New event',
						'view_item' => 'View event',
						'search_items' => 'Search ',
						'not_found' =>  'No event found',
						'not_found_in_trash' => 'No event found in Trash',
						'parent_item_colon' => ''
				),
				'public' => true,
				'publicly_queryable' => true,
				'show_ui' => true,
				'query_var' => true,
				'rewrite' => true,
				'capability_type' => 'post',
				'hierarchical' => false,
				'menu_position' => 5,
				'menu_icon' => '',
				'supports' => array(
						'title','editor','thumbnail','custom-fields'
				),
				'has_archive' => true
		);

		register_post_type('events', $event_args);
}

ikonę definiujemy z fontu dashicons, klikając na Copy css otrzymujemy odpowiedni kod, np: content: „\f309”;

następnie dodajemy style css do admin head poprzez:


//create custom post icon in menu admin panel
function add_menu_icons_styles(){ ?>


<style>
#adminmenu .menu-icon-events div.wp-menu-image:before {
	content: '\f309';
}
</style>


<?php
}
add_action( 'admin_head', 'add_menu_icons_styles' );


'menu_icon' => plugins_url( 'images/image.png', __FILE__ ),
'menu_icon' => 'dashicons-hammer',

 

dodanie koloru, stylu dla ikony (lub innego dowolnego elementu w panelu admina)


//add style color icon
add_action('admin_head', 'my_custom_colors');
function my_custom_colors() {
echo '<style>
#adminmenu div.wp-menu-image.dashicons-hammer:before,
#adminmenu div.wp-menu-image.dashicons-images-alt:before {
color: rgba(240,90,26,.6);
}
</style>';
}