看到下边的图片效果了吗?这就是代码实现wordpress添加书签下拉菜单,怎么样不错吧,想要就赶紧行动吧,下边有代码哦
把下面这段代码添加到functions.PHP中,你的管理BAR中就可以添加一个书签链接,放入你常用的链接,是下拉菜单式样的。
function wps_adminbar_bookmarks() { global $wp_admin_bar; $cat = '2'; // define category $name = 'Bookmarks'; $bookmarks = array(); $bookmarks = get_bookmarks("category=$cat"); if ($bookmarks[0] != '') { $wp_admin_bar->add_menu( array( 'title' => $name, 'href' => false, 'parent' => false )); foreach ( $bookmarks as $bookmark ) { $wp_admin_bar->add_menu( array( 'title' => $bookmark->link_name, 'href' => clean_url($bookmark->link_url),liehuo.net 'parent' => strtolower($name), 'Meta' => array('target' => '_blank'), )); } } } add_action('admin_bar_menu','wps_adminbar_bookmarks',500);