Another code for creating bookmarks in the admin bar for blog authors
Embed a similar code on my website., so that the author can view all the resources they need, namely, while this is the transition code to my news in various social networks. So what does the code do.
First you add a link to the section links in the admin area WordPress and make it available to everyone. Then copy the code fragment from my article to your file functions.php. Go to the administration panel, if everything was done right, that added links will be displayed as bookmarks in the admin bar.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
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), 'parent' => strtolower($name), 'meta' => array('target' => '_blank'), )); } } } add_action('admin_bar_menu', 'wps_adminbar_bookmarks', 500); |
Code checked, everything works great. Add to your sites, good luck with the moderators WordPress.
/*
- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.