I’d like to enable the Recent posts widget with the ability to show a “View All” link when there are more posts than I’ve currently got the widget set to show.
I’d also like to be able to exclude certain categories or posts from it.
Is it possible to do either via my theme’s functions.php?
(1) Customize the existing widget or (2) Create a copy of it that I can customize?
It’s usually best to copy the existing one, name it something unique, and then add your own functionality.
Copy the
WP_Widget_Recent_Posts
class from wp-includes/class-wp-widget-recent-posts.php into your functions.php (or, preferably, another file in your theme devoted just to widgets) and rename to something else, likeMy_Widget_Recent_Posts
Add your functionality in there.
Don’t forget to call
register_widget('My_Widget_Recent_Posts')
as part of theinit
phase as well.