Rumah > php教程 > php手册 > Add a Submenu to the WordPress Admin Bar

Add a Submenu to the WordPress Admin Bar

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Lepaskan: 2016-06-06 20:14:18
asal
1336 orang telah melayarinya

Read the full article at: Add a Submenu to the WordPress Admin Bar A while back I wrote Add Menu Items to the WordPress Admin Menu, a post detailing how you can add items to the left side, existing posts menu bar. ?Adding menu items?has se

Read the full article at: Add a Submenu to the WordPress Admin Bar

Treehouse

A while back I wrote Add Menu Items to the WordPress Admin Menu, a post detailing how you can add items to the left side, existing “posts” menu bar. ?Adding menu items?has served me well but it’s not as customized as I would like — I’m still adapting to WordPress instead of WordPress adapting to me. ?By creating a custom top bar menu, I can mix and match links all I want!

Like adding functionality to your?theme and other admin?area,?the directives will go in your theme’s functions.php file. ?The code itself should be self explanatory:

function create_dwb_menu() {
	global $wp_admin_bar;
	$menu_id = 'dwb';
	$wp_admin_bar->add_menu(array('id' => $menu_id, 'title' => __('DWB'), 'href' => '/'));
	$wp_admin_bar->add_menu(array('parent' => $menu_id, 'title' => __('Homepage'), 'id' => 'dwb-home', 'href' => '/', 'meta' => array('target' => '_blank')));
	$wp_admin_bar->add_menu(array('parent' => $menu_id, 'title' => __('Drafts'), 'id' => 'dwb-drafts', 'href' => 'edit.php?post_status=draft&post_type=post'));
	$wp_admin_bar->add_menu(array('parent' => $menu_id, 'title' => __('Pending Comments'), 'id' => 'dwb-pending', 'href' => 'edit-comments.php?comment_status=moderated'));
}
add_action('admin_bar_menu', 'create_dwb_menu', 2000);
Salin selepas log masuk

Setting an id on the parent menu item allows you to use the parent key for submenu items; the rest of the keys are easy to figure out. ?With the menu created, you simply need to add the WordPress hook and specificity to add it!

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Cadangan popular
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan