您可以在Wordpress上添加自定义仪表板徽标吗?

时间:2017-01-12 14:20:51

标签: php css wordpress wordpress-theming custom-wordpress-pages

我想替换左上方仪表板中的Wordpress徽标?那里有一个' W'

这可能吗?

2 个答案:

答案 0 :(得分:1)

是的,你可以,2种方式:

  1. 插件:White Label CMS wordpress plugin
  2. 通过代码:
  3.   

    首先,您需要将自定义徽标另存为custom-logo.png文件   你的电脑。它的尺寸必须精确16 x 16px

         

    准备好自定义徽标后,需要将其上传到   使用FTP的/wp-content/themes/your-theme/images文件夹。如果你的主题   没有图像文件夹,那么你需要创建它。

         

    上传自定义徽标图片后,只需将此代码添加到您的   主题的functions.php文件或特定于网站的插件。

    function wpb_custom_logo() {
        echo '<style type="text/css">
        #wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before {
        background-image: url(' . get_bloginfo('stylesheet_directory') . '/images/custom-logo.png) !important;
        background-position: 0 0;
        color:rgba(0, 0, 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('wp_before_admin_bar_render', 'wpb_custom_logo');
    

    您可以在此处找到更多信息:http://www.wpbeginner.com/wp-themes/adding-a-custom-dashboard-logo-in-wordpress-for-branding/

答案 1 :(得分:0)

function wpb_custom_logo() {
echo '
<style type="text/css">
#wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before {
background-image: url(' . get_bloginfo('stylesheet_directory') . '/images/custom-logo.png) !important;
background-position: 0 0;
color:rgba(0, 0, 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('wp_before_admin_bar_render', 'wpb_custom_logo');

上传徽标后将此代码添加到functions.php中(16x16)