WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

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.