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.
Instructions:
All you have to do is add this code to your category.php file:
<select onchange="location = this.options[this.selectedIndex].value;"> <?php $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 }} ?> </select>
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