更改WordPress中自定义帖子类型的图标以使用Twitter引导

时间:2013-02-21 作者:TheWebs

使用jquery,WordPress管理菜单的图标已更改为使用twitter boostrap图标,如:

jQuery(\'#icon-themes.icon32\').replaceWith(\'<div style="font-size:22px;" class="icon32 fonticon"><i class="icon-eye-open icon-large"></i></div> \');
但我有自定义的帖子类型图标,我想用推特boostrap中的图标来替换。问题是我不确定要瞄准什么。

one的源代码如下所示:(这是一个菜单项的源代码,它是一个自定义的post类型)

  <ul>
    <li class="wp-has-submenu wp-not-current-submenu menu-top menu-icon-mini-feed" id=
    "menu-posts-mini-feed"><a href=\'edit.php?post_type=mini-feed\' class=
    "wp-has-submenu wp-not-current-submenu menu-top menu-icon-mini-feed" aria-haspopup=
    "true"></a></li>
  </ul>

  <div class="wp-menu-arrow"></div>

  <div class=\'wp-menu-image\'><img src=
  "http://icons.iconarchive.com/icons/fatcow/farm-fresh/32/folders-icon.png" alt=
  "" /></div>

  <div class=\'wp-menu-name\'>
    Mini-Feed
  </div>

  <ul class=\'wp-submenu wp-submenu-wrap\'>
    <li class=\'wp-submenu-head\'>Mini-Feed</li>

    <li class="wp-first-item"><a href=\'edit.php?post_type=mini-feed\' class=
    "wp-first-item">All Mini-Feeds</a></li>

    <li><a href=\'post-new.php?post_type=mini-feed\'>New Mini-Feed</a></li>
  </ul>
有什么想法吗?

1 个回复
最合适的回答,由SO网友:Brooke. 整理而成

我总是喜欢使用this tutorial 这会给你这个密码。

<?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 } ?>

结束