如何从管理员处更改wordpress默认徽标?

如何从管理员处更改wordpress默认徽标?,wordpress,Wordpress,我想创建一个自定义徽标,因此需要更改wordpress徽标的默认徽标。以下是将正确覆盖管理员徽标的函数(插入functions.php中): /** * customize the admin logo that appears in the header * http://www.wpbeginner.com/wp-themes/adding-a-custom-dashboard-logo-in-wordpress-for- branding/ * @author Paul Bre

我想创建一个自定义徽标,因此需要更改wordpress徽标的默认徽标。

以下是将正确覆盖管理员徽标的函数(插入functions.php中):

/**
* customize the admin logo that appears in the header
* http://www.wpbeginner.com/wp-themes/adding-a-custom-dashboard-logo-in-wordpress-for-       branding/
* @author Paul Bredenberg
*/

function htx_custom_logo() {
echo '
<style type="text/css">
#wp-admin-bar-wp-logo > .ab-item .ab-icon { 
background-image: url(' . get_bloginfo('stylesheet_directory') . '/assets/images/dashboard-logo.png) !important; 
background-position: 0 0;
}
#wpadminbar #wp-admin-bar-wp-logo.hover > .ab-item .ab-icon {
background-position: 0 0;
}   
 </style>
';
}

 //hook into the administrative header output
add_action('admin_head', 'htx_custom_logo');
/**
*自定义标题中显示的管理员徽标
* http://www.wpbeginner.com/wp-themes/adding-a-custom-dashboard-logo-in-wordpress-for-       品牌/
*@作者保罗·布雷登伯格
*/
功能htx_自定义_徽标(){
回声'
#wp管理栏wp logo>.ab item.ab图标{
背景图片:url('.get_bloginfo('stylesheet_directory')。/assets/images/dashboard logo.png)!重要;
背景位置:0;
}
#wpadminbar#wp-admin-bar-wp-logo.hover>.ab item.ab图标{
背景位置:0;
}   
';
}
//钩住管理标头输出
添加操作(“管理头”、“htx自定义标识”);
从这里开始:


这里有一个很好的插件,用于此功能,还有更多功能

function my\u login\u logo(){?>
body.login div#login h1 a{
背景图片:url(/images/site login logo.png);
填充底部:30px;
}

使用以下代码将仪表板徽标更改为自定义徽标:

add_action('admin_head', 'my_custom_logo');

function my_custom_logo() {
echo '
<style type="text/css">
#header-logo { background-image: url('.get_bloginfo('template_directory').'/images/custom-logo.gif) !important; }
</style>
';
}
add_action('admin_head'、'my_custom_logo');
功能my_自定义_徽标(){
回声'
#标题徽标{背景图像:url('.get_bloginfo('template_directory')。/images/custom logo.gif)!重要;}
';
}
我做了一些安排:
-支持全屏模式
-使用站点的favicon,以便为多站点自动定制,如果没有favicon,您可以放置一些默认图像)
我把“宽度:12px”作为favicon封面背景的正方形
如果它能帮助某人,请输入以下代码:

function my_custom_admin_logo() {
    echo '
        <style type="text/css">
            #wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before {content:none;}
            #wpadminbar #wp-admin-bar-wp-logo > a {
                background-image: url(' . get_site_icon_url() . ') !important;
                background-size: cover !important;
            }
            #wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon {width: 12px;}
            @media screen and (max-width:782px){ #wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon {width: 46px;} }
            a.edit-post-fullscreen-mode-close.has-icon {
                background-image: url(' . get_site_icon_url() . ');
                background-size: cover;
            }
            .edit-post-fullscreen-mode-close.has-icon > svg > path { display: none;}
        </style>
    ';
}
//hook into the administrative header output
add_action('wp_before_admin_bar_render', 'my_custom_admin_logo');
function my\u custom\u admin\u logo(){
回声'
#wpadminbar#wp admin bar wp logo>.ab item.ab图标:在{content:none;}之前
#wpadminbar#wp admin bar wp logo>a{
背景图片:url('.get_site_icon_url())!重要信息;
背景尺寸:封面!重要;
}
#wpadminbar#wp admin bar wp logo>.ab item.ab图标{宽度:12px;}
@媒体屏幕和(最大宽度:782px){wpadminbar}wp admin bar wp logo>.ab item.ab图标{width:46px;}
a、 edit-post-fullscreen-mode-close.has-icon{
背景图片:url('.get_site_icon_url());
背景尺寸:封面;
}
.edit-post-fullscreen-mode-close.has-icon>svg>path{display:none;}
';
}
//钩住管理标头输出
添加动作(“管理前的wp\u条渲染”、“我的自定义管理标识”);

Sunny的回答仅覆盖该项目的图标。如果要完全删除该项目,可以执行以下操作:

function htx_custom_logo() {
  echo '
    <style type="text/css">
      #wpadminbar #wp-admin-bar-wp-logo>.ab-item { 
       display:none;
      }
    </style>
  ';
}

 //hook into the administrative header output
add_action('admin_head', 'htx_custom_logo');
功能htx\u自定义\u徽标(){
回声'
#wpadminbar#wp admin bar wp logo>.ab项{
显示:无;
}
';
}
//钩住管理标头输出
添加操作(“管理头”、“htx自定义标识”);
我还必须做#wpadminbar#wp admin bar wp logo>.ab item.ab icon:在{content:none}之前,因为wp logo仍然存在
function htx_custom_logo() {
  echo '
    <style type="text/css">
      #wpadminbar #wp-admin-bar-wp-logo>.ab-item { 
       display:none;
      }
    </style>
  ';
}

 //hook into the administrative header output
add_action('admin_head', 'htx_custom_logo');