List monthy archives for specific year with wp_get_archives
Question
I just want a simple list with the monthly archives for one specific year. Like so:
- January
- February
- March
- April
- etc.
I don’t need anything fancy like yearly grouping. Ideally I would like a shortcode like this [month-archive year=2019]. This is how far I’ve come but the ‘Year’ parameter does not seem to do anything.
function my_monthly_archives() {
$my_archives = wp_get_archives(array(
'type'=>'monthly',
'limit'=>10,
'echo'=>0,
'year'=>'2018'
));
return $my_archives;
}
// Create a shortcode
add_shortcode('month-archive', 'my_monthly_archives');
// Enable shortcode execution in text widget
add_filter('widget_text', 'do_shortcode');
0
archives, shortcode, widgets
4 years
2020-03-28T20:50:58-05:00
2020-03-28T20:50:58-05:00 0 Answers
115 views
0
Leave an answer