Hey all -
I'm trying to do a "month by meta" url list, the idea is based upon this post here in the forums.
I believe I'm getting the query correct, because when I echo after each step, then my output is doing what it should be doing. What I have right now is this:
} elseif ( 'catmonthly' == $type ) {
$arcresults = $wpdb->get_results("SELECT DISTINCT
$wpdb->postmeta.meta_value AS date, count(ID) as posts FROM $wpdb->posts, $wpdb->post2cat, $wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.post_id = $wpdb->postmeta.post_id AND $wpdb->post2cat.category_id = '$mcat' AND $wpdb->postmeta.meta_key='newsletter_month_year' AND $wpdb->posts.post_type = 'post' AND $wpdb->posts.post_status = 'publish' GROUP BY $wpdb->postmeta.meta_value ORDER BY meta_value DESC");
if ( $arcresults ) {
$afterafter = $after;
foreach ( $arcresults as $arcresult ) {
$date = $arcresult->date;
list($month, $year) = split(' ', $date);
//test line - uncomment to test
//echo $month . " " . $year . "<br />";
$url = get_month_link($year,$month) . "?cat=" .$mcat;
$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($month), $year);
if ( $show_post_count )
$after = ' ('.$arcresult->posts.')' . $afterafter;
echo get_archives_link($url, $text, $format, $before, $after);
}
}
}
So, when you get to the "list(split...)" line, I've put in a test line right after it that echoes out the $month and $year - just a quickie test to be sure the correct output is being generated. According to the echo statement, it is - it's outputting the correct $month and $year every time. However...
the very next line is:
$url = get_month_link($year,$month) . "?cat=" .$mcat;
Now, since the test echo statement says the correct info is being parsed as $month and $year, it stands to reason that the "$year,$month" part in the "get_month_link()" area would snap up these correct values - but they are not. $year comes through just fine, but $month is ignored for some reason. So when my links list comes through, it lists the year, but no month. I basically have a list of links that all say "2007", and each one is linked to "domain.com/2007/00/?cat=13".
Would anyone know why this is? It really doesn't make any sense to me, since it's echoing the values correctly *just* before the get_month_link()...so I don't know why it's not coming through to the next few areas.