Custom post type custom icon

// register the post type
register_post_type( static::POSTTYPE, array(
	'menu_icon' => __( plugins_url( 'icon-16x16.png' , __FILE__ ), 'custom_plugin' ),
	)
);

// Style change for 32x32 icon for custom post type
add_action('admin_head', 'custom_header');

function custom_header() {
	global $post_type;
		?>
		<style>
			<?php if (($_GET['post_type'] == 'custom_plugin') || ($post_type == 'custom_plugin')) : ?>
				#icon-edit { background:transparent url('<?php echo plugins_url( 'icon-32x32.png' , __FILE__ ) ?>') no-repeat; }
			<?php endif; ?>
		</style>
		<?php
}

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.