Custom Svg Admin Menu Icon in Wordpress

Custom svg admin menu icon in WordPress

I got the solution by analyzing Woocommerce. If no url is supplied to the add_menu_page function, WordPress uses the default dashicon. So it's just a matter of overriding the default style. Like add this to admin styles:

#adminmenu #toplevel_page_yourpageid .menu-icon-generic div.wp-menu-image:before {
font-family: your_font !important;
content: '\eiconid';
font-size: 1.3em!important;
}

I converted svg to font on Icomoon.

WordPress Custom Theme Favicon in Dashboard Menu

I figured this one out. Hopefully it can help others:

add_menu_page('Page title', 'Top-level menu title', 
'administrator', 'my-top-level-handle',
'my_magic_function','../wp-content/themes/yourTheme/img/favicon.png');

You can also add a submenu under your theme's main menu item like so...

add_submenu_page( 'my-top-level-handle', 'Page title',
'Sub-menu title', 'administrator', 'my-submenu-handle', 'my_magic_function')

How can i add new item to wordpress sidemenu, with icon on it

refrence https://core.trac.wordpress.org/browser/tags/3.2.1/wp-admin/menu.php

<?php 

add_action('admin_init', 'logout_menu_item_link');

function logout_menu_item_link() {
global $menu;
$menu[9999] = array(__('Logout'), 'read', wp_logout_url(),'','custom-class','custom-id','dashicons-external');

}


Related Topics



Leave a reply



Submit