How to Add Bookmarks in Dropdown List in WordPress

Snippets by IsItWP

Are you looking for a way to add your bookmarks within whatever category you choose to be displayed within a select menu? While there’s probably a plugin for this, we have created a quick code snippet that you can use to add bookmarks in dropdown list in WordPress.


All you have to do is add this code to your category.php file:

<select onchange="location = this.options[this.selectedIndex].value;">
			$bookmarks = array();
			$bookmarks = get_bookmarks("category=3");
		if ($bookmarks[0] != '') { ?>

		<?php foreach ( $bookmarks as $bookmark ) {?>
			<option value="<?php echo clean_url($bookmark->link_url); ?>"> <?php echo $bookmark->link_name; echo $bookmarks->term_id; ?> - <?php echo $bookmark->link_description; ?></option>
		<?php }} ?>

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 20 best WordPress church themes and how to start a blog.

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!
[63% OFF Today!]
[63% OFF Today!]
[50% OFF Today!]
[50% OFF Today!]
[60% OFF Today!]
[60% OFF Today!]
[50% OFF Today!]
[50% OFF Today!]