I'm looking for a way to get the values returned from wp_get_archives
as an array, similar to get_categories
. I need to do this to modify the post counters to use - [#]
instead of (#)
. See my current code below:
My code for categories, which displays as desired:
$cats = get_categories();
if ($cats) {
echo "<section class='widget'>";
echo "<header><h4>Categories</h4></header>";
echo "<ul>";
foreach ($cats as $cat) {
echo "<li><a href='" . get_category_link($cat->term_id) . "'>" . $cat->name . "</a> - [" . $cat->count . "]</li>";
}
echo "</ul>";
echo "</section><!--/.widget-->";
}
My code for archvies, which does not display as desired:
$archives = wp_get_archives(array(
"echo" => 0,
"show_post_count" => true,
));
if ($archives) {
echo "<section class='widget'>";
echo "<header><h4>Archives</h4></header>";
echo "<ul class='cats'>" . $archives . "</ul>";
echo "</section><!--/.widget-->";
}