Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Can you please take a look at following code and let me know why i am not able to add icons to custom post type?

add_action( 'admin_head', 'my_icons' );
function my_icons() {?>
<style type="text/css" media="screen">
 #menu-posts-product .wp-menu-image {
 background: url(<?php bloginfo('url') ?>/wp-content/themes/BootWp/img/contactLensemenu.png) no-repeat 6px !important;}
 .icon32-posts-product {
 background: url(<?php bloginfo('url') ?>/wp-content/themes/BootWp/img/contactLensepage.png) no-repeat !important;
    }
</style>
<?php } 

I have checked the root and image file existence, they are all correct but the code not working

share|improve this question
    
for the admin main menu post type icon image you can define 16x16px icon in register_post_type(); $args by using "menu_icon" key, see the codex –  Anjum Aug 21 '13 at 18:53
    
@Anjum, yes, but if the registration is done by another pulgin that not provide filter for that... Also OP want change the icon shown in the edit page, that you cannot change with register_post_type –  G. M. Aug 21 '13 at 18:57
    
@G.M. yes but it's only my advice for menu icon not for edit screen icon and it's not my answer, it is a comment. –  Anjum Aug 21 '13 at 19:01
add comment

1 Answer

This code works perfectly for me:

add_action( 'admin_head', 'my_icons' );

function my_icons() { ?>
 <style type="text/css" media="screen">
 #menu-posts-product .wp-menu-image, .icon32-posts-product {
     background: url(<?php echo get_template_directory_uri();  ?>/img/contactLensemenu.png) no-repeat center center!important;
 }
 #menu-posts-product .wp-menu-image { background-size:16px 16px!important; }
 .icon32-posts-product { background-size:32px 32px!important; }
 </style>
<?php } ?>

PHP part is the same of the yours, (except for get_template_directory_uri() that I use for convenience, because it is equivalent to your /wp-content/themes/BootWp`) I changed a bit the css, but I down know dimension of your image, the mine is 64X64px.

My WP is 3.6 and the product post type is registered by WooCommerce.

share|improve this answer
    
Hi G.M Thanks for comment. I am also using WordPress 3.6 but it doesnt works for me! I have the same code with WordPress 3.5.1 and working perfectly but on this one is not working! –  Mona Coder Aug 21 '13 at 20:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.