Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How to make one query for display a list of links like this:

Date 05/20/2012
Category - Link
Category - Link
Category - Link
Category - Link
Category - Link

Date 05/19/2012
Category - Link
Category - Link
Category - Link
Category - Link
Category - Link

....

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

Try it like this:

$dates = array(); // declare an array to hold dates

echo '<ul>';

if (have_posts()) : while (have_posts()) : the_post(); 

    $thisday = get_the_time('m/d/Y'); // this post's date

if (!in_array($thisday,$dates)) { // check if it's in the array
    echo '<h5>Date '.$thisday.'</h5>'; // if not, print header with date
    $dates[] = $thisday; // and store it
}

echo '<li>';
the_category();
echo '</li>';

endwhile;
endif;

echo '</ul>';
share|improve this answer
    
Thanks moraleida, this works great. Was that i wanted, so much thanks. –  Johny May 22 '12 at 21:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.