I've generated an array of dates. Here is a quick sample
Array
(
[2013] => Array
(
[Feb] => 2013
[Jan] => 2013
)
[2012] => Array
(
[Oct] => 2012
[Jun] => 2012
[May] => 2012
)
)
Sample code:
<?php
$posts = get_posts(array('numberposts' => -1, 'post_status' => 'publish', 'post_type' => 'post', ));
# $i=1;
print '<pre>';
foreach ($posts as $post) {
# $post_results[$post->ID][month] = get_the_time('m', $post->ID);
# $post_results[$post->ID][year] = get_the_time('Y', $post->ID);
$year = get_the_time('Y', $post -> ID);
$month = get_the_time('M', $post -> ID);
$post_results[$year][$month] = get_the_time('Y', $post -> ID);
# echo "$i. Post ID: " .$post->ID." - " .get_the_time('Y-m-d', $post->ID)."<br/>";
# $i++;
}
foreach ($post_results as $key => $value) {
echo "Month: " . $key . " Year: " . $value . "<br/>";
}
print_r($post_results);
print '</pre>';
?>
I'd like to list all dates in the same format as this webpage http://www.smartpassiveincome.com/archives/
What I need is help getting my array to separate values like what you see above. I can do the linking part myself, I just need the data pulled into easy to use variables for me.
For example, I'd like to say "For each year, get all the months listed, then type out <td>$year</td><td>$month</td>
then move on to the previous year.