Created
July 18, 2012 14:49
-
-
Save corsonr/3136641 to your computer and use it in GitHub Desktop.
Add a cpt icon the right way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* ------------------------------------------------------------------*/ | |
/* CUSTOM CPTs ICONS */ | |
/* ------------------------------------------------------------------*/ | |
// let's say you custom post type is : portfolio | |
add_action( 'admin_head', 'cpt_icons' ); | |
function cpt_icons() { | |
?> | |
<style type="text/css" media="screen"> | |
#menu-posts-portfolio .wp-menu-image { | |
background: url(<?php get_template_directory_uri(); ?>/images/portfolios-icon.png) no-repeat 6px -17px !important; | |
} | |
#menu-posts-portfolio:hover .wp-menu-image, #menu-posts-portfolio.wp-has-current-submenu .wp-menu-image { | |
background-position:6px 7px!important; | |
} | |
</style> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should probably use get_template_directory_uri() instead of bloginfo('template_url'), or the stylesheet equivalent (for child themes). Also, prefix your function :)