简体   繁体   English

如何更改 WordPress 管理区域中的默认 Dashicon?

[英]How do I change a default Dashicon in WordPress Admin area?

So I am renaming my "Posts" in WordPress backend to "News" and was able to use the code (thanks to Chris Perryman ) added to my functions.php file but I would also like to change the default dashicon as well to: dashicons-media-document instead of the default "dashicons-admin-post"因此,我将 WordPress 后端中的“帖子”重命名为“新闻”,并且能够使用添加到我的 functions.php 文件中的代码(感谢Chris Perryman ),但我也想将默认的dashicon 更改为: dashicons -media-document而不是默认的“dashicons-admin-post”

I have tried adding: $labels->icon_url = 'dashicons-media-document';我尝试添加: $labels->icon_url = 'dashicons-media-document'; but that doesn't work for some reason or other?但这由于某种原因不起作用?

Thank-you in advance for any help!预先感谢您的任何帮助!

function revcon_change_post_label() {
    global $menu;
    global $submenu;
    $menu[5][0] = 'News';
    $submenu['edit.php'][5][0] = 'News';
    $submenu['edit.php'][10][0] = 'Add News';
    $submenu['edit.php'][16][0] = 'News Tags';
}
function revcon_change_post_object() {
    global $wp_post_types;
    $labels = &$wp_post_types['post']->labels;
    $labels->name = 'News';
    $labels->singular_name = 'News';
    $labels->add_new = 'Add News';
    $labels->add_new_item = 'Add News';
    $labels->edit_item = 'Edit News';
    $labels->new_item = 'News';
    $labels->view_item = 'View News';
    $labels->search_items = 'Search News';
    $labels->not_found = 'No News found';
    $labels->not_found_in_trash = 'No News found in Trash';
    $labels->all_items = 'All News';
    $labels->menu_name = 'News';
    $labels->name_admin_bar = 'News';
}
 
add_action( 'admin_menu', 'revcon_change_post_label' );
add_action( 'init', 'revcon_change_post_object' );

I would like to be able to just add a simple line or two of code to my custom-themes' function.php so this will all get updated on a new install.我希望能够在我的自定义主题的 function.php 中添加一两行简单的代码,以便在新安装时全部更新。

Use CSS使用 CSS

function bks_replace_admin_menu_icons_css() {
    ?>
    <style>
        .dashicons-admin-post:before {
            font-family: "dashicons";
            content: "\f497" !important;
        }
    </style>
    <?php
}

add_action( 'admin_head', 'bks_replace_admin_menu_icons_css' );

在此处输入图片说明

Code goes inside functions.php file.代码位于functions.php文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Wordpress - 如何按表中的列对管理区域进行排序 - Wordpress - How can I sort admin area by column in the table 在Wordpress中,如何将自定义帖子类型的默认管理排序顺序设置为自定义列? - In Wordpress, how do I set the default admin sort order for a custom post type to a custom column? 如何更改Network Super Admin WordPress的默认用户名? - How to change default UserName for Network Super Admin WordPress? 如何更改wordpress的十二个标头php管理员选项,以包括上载徽标部分? - How do I change the wordpress twenty twelve header php admin options to include an upload logo section? 更改WordPress管理/后端中的默认页面顺序 - Change default order of pages in WordPress Admin / Backend Wordpress管理区域中的标签? - Tabs in wordpress admin area? 如何从 flickr 默认宽度更改 Wordpress 的 TwentyTen 自动嵌入(更新问题)? - How do I change Wordpress's TwentyTen auto-embed from flickr default width (UPDATED QUESTION)? 如何在没有管理员权限的情况下在wordpress中安装插件 - how do I install a plugin in wordpress without admin access 如何在Wordpress管理窗口小部件中包含javascript文件 - How do I include a javascript file in Wordpress admin Widgets 如何在Wordpress的管理侧栏中显示“帖子”? - How do I get “posts” to show up in the admin sidebar in wordpress?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM