Tengo este codigo en el function.php el cual me crear la lista de los meses en los cuales se han creado post asi:
Código PHP:
Ver originalfunction twentyeleven_get_archives_callback($item, $index, $currYear) {
global $wp_locale;
if ( $item['year'] == $currYear ) {
$url = get_month_link( $item['year'], $item['month'] );
// translators: 1: month name, 2: 4-digit year
$text = sprintf(__
('%1$s %2$d'), $wp_locale->get_month($item['month']), $item['year']); echo get_archives_link($url, $text);
}
}
function twentyeleven_get_archives() {
global $wpdb;
$query = "SELECT YEAR(post_date) AS <code>year</code> FROM $wpdb->posts WHERE <code>post_type</code> = 'post' AND <code>post_status</code> = 'publish' GROUP BY <code>year</code> ORDER BY <code>year</code> DESC limit 4";
$arcresults = $wpdb->get_results($query);
if ($arcresults) {
foreach ( (array)$arcresults as $arcresult ) { }
}
$query = "SELECT YEAR(post_date) as <code>year</code>, MONTH(post_date) as <code>month</code> FROM $wpdb->posts WHERE <code>post_type</code> = 'post' AND <code>post_status</code> = 'publish' GROUP BY <code>year</code>, <code>month</code> ORDER BY <code>year</code> DESC, <code>month</code> ASC";
$arcresults = $wpdb->get_results($query, ARRAY_A);
if ( $arcresults ) {
foreach ($years as $year) {
//My Display
//echo "\t<li>\n\t\t<a href=\"#\">$year</a>\n\t\t<ul>\n";
//array_walk($arcresults, "twentyeleven_get_archives_callback", $year);
//echo "\t\t</ul>\n\t</li>\n";
//Your Display
echo "\t<div class='listYearArchive'><span class='yearArchive'>$year</span>\n\t<ul class='listMonthArchive'>\n";
array_walk($arcresults, "twentyeleven_get_archives_callback", $year); echo "\t</ul></div>\n";
}
}
}
2015 nov dec
2104 may nov dec
"nov" "dec" son link el cual me muestra en la url:
http://www.xxx.com/2015/11 los post de esa fecha.
Esto usando archive.php
La pregunta es: como podria hacer esto mismo pero filtrando estos link por custom post type ??