You’re probably familiar with the Category widget in WordPress. Recently, one of our readers asked us if it was possible to display recent posts in a drop down as well. In this article, we will show you how to show recent posts as a drop down in WordPress.
WHY AND WHO NEEDS RECENT POSTS IN DROP DOWN?
WordPress comes with a built-in recent posts widget that you can add to any sidebar or widget ready area.
This widget simply displays a list of recent posts, and you can choose the number of posts you want to show. But if you want to show more than 5-10 posts, then the list will take a lot of space in your sidebar.
Some WordPress users may need a compact way to display recent posts. In that case, using drop downs or collapsible lists can help you save space.
Let’s take a look at couple of different ways to show recent posts as a drop down menu in WordPress.
SHOWING WORDPRESS RECENT POSTS IN A PLAIN DROP DOWN MENU (MANUAL CODE)
This method uses the built-in
wp_get_recent_posts function. All you need to do is copy and paste the following code in your theme’s functions.php file or a site-specific plugin.
Source: Recent post drop down