0815

Du musst dich anmelden um Beiträge und Themen zu erstellen. Einloggen · Registrieren

How to Add Additional Links to wp_list_pages

Here is a nice way to include additional links to the output of the wp_list_pages tag. All that’s needed is the following function in your functions.php file:

// include additional links
function add_bookmarks_to_menu($output) {
	$bookmarks = (array) get_bookmarks('hide_invisible=0&category_name=wp_list_pages');
	foreach ($bookmarks as $bookmark) {
		$output .= "<li><a href='{$bookmark->link_url}'  title='{$bookmark->link_name}'>{$bookmark->link_name}</a></li>\n";        

	}
	return $output;
}
add_filter('wp_list_pages', 'add_bookmarks_to_menu');

Here we are taking advantage of WordPress’ built-in Links/Bookmarks functionality to assign new links to the output of the wp_list_pages tag. Once this code is in place, login to your WordPress Admin and follow these steps for each link that you would like to add to the page list:

  1. In the Admin, go to Links > Add New
  2. Enter a name and URL for your link
  3. Add the link to a new category called “wp_list_pages”
  4. select “Keep this link private”
  5. Click “Add Link”
  6. Done.

Using the “wp_list_pages” category for any/all of our extra links will enable us to include only links from that category. Further, selecting the “Keep this link private” option will prevent the links from being displayed elsewhere in your site (for example, in the Links/Blogroll/Bookmark sections).

Source: sivel.net (404 link removed 2015/10/18)




0