====================================================
Howto: Como gerar um menu agrupando as postagem por ano e mês
====================================================
A idéia é fazer um menu assim:
2009
- Maio
- Abril
- Março
- Fevereiro
- Janeiro
2008
- Dezembro
- Novembro
O código é simples:
<ul>
<?php
/**/
$years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date)
FROM $wpdb->posts WHERE post_status = "publish"
AND post_type = "post" ORDER BY post_date DESC");
foreach($years as $year) :
?>
<li><a href="<?php echo get_year_link($year); ?> ">
<?php echo $year; ?></a>
<ul>
<? $months = $wpdb->get_col("SELECT DISTINCT MONTH(post_date)
FROM $wpdb->posts WHERE post_status = "publish"
AND post_type = "post" AND YEAR(post_date) = "".$year.""
ORDER BY post_date DESC");
foreach($months as $month) :
?>
<li><a href="<?php echo get_month_link($year, $month); ?>">
<?php echo date( "F", mktime(0, 0, 0, $month) );?></a></li>
<?php endforeach;?>
</ul>
</li>
<?php endforeach; ?>
</ul>
Bacana o exemplo
Saberia me dizer como faço para agrupar os posts por ano, exibindo o título deles e filtrando por uma determinada categoria? Estou tentando isso há dias e não consigo.
Exemplo:
2010
Construindo o Saber
SOS Cachoeira
Diagnóstico Laticínio – SEBRAE
2009
Planejamento de Marketing
Curso de Logística e Supply Chain