Skip Navigation

[Closed] WP variable for CPT admin icon?

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 3 replies, has 2 voices.

Last updated by Adriano 8 years, 3 months ago.

Assigned support staff: Adriano.

Author
Posts
#123518

The icons on the admin screen are coming from a file containing about 16 images. This means that there's a WP function to position that image to the correct icon.

That means that there's probably WP variables that could be dropped into the CPT icon field. I rather use the icons in the admin section without cluttering the Media section of WP, if possible.

Great set of plug-ins, by the way.

#123974

Dear patrickM-3,

You should paste the code below in functions.php file:

<?php
add_action( 'admin_head', 'cpt_icons' );
function cpt_icons() {
    ?>
    <style type="text/css" media="screen">
        #menu-posts-POSTTYPE .wp-menu-image {
            background: url(<?php bloginfo('template_url') ?>/images/YOURIMAGE.png) no-repeat 6px -17px !important;
        }
        #menu-posts-POSTTYPE:hover .wp-menu-image, #menu-posts-POSTTYPE.wp-has-current-submenu .wp-menu-image {
            background-position:6px 7px!important;
        }
    </style>
<?php } ?>

Then you need to change the "POSTTYPE" string with the correct call name, fix the positions and use the correct image names.

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

#124027

Awesome! Thanks a ton.

By the way - the URL for the image - should that be relative to the theme folder or wp-admin folder?

#124141

Should be relative to the theme folder. I don't recommend to change things in the wp-admin folder cause a update might lost it.

Is there something else I can help you?

The topic ‘[Closed] WP variable for CPT admin icon?’ is closed to new replies.