• hey guys.. here is what i am trying to say today is Aug 08, 2010..so what will show is

    Aug 08, 2010
    Post title 1
    Post title 2
    and so on for the other post for this date

    Aug 08, 2010
    Post title 1
    Post title 2
    and so on for the other post for this date

    but i also want to show this only 3 time. so it will show all the post grouped by dates for last 3 days.

    thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter opblog

    (@opblog)

    hey thanks i got this but stuck on one thing i want to put category name with the post that showing here.. how can i do that…

    <?php
      global $wpdb;
      $splitformat = '%A %B %Y';
      $sql = "SELECT ID, post_title, post_date
    			FROM $wpdb->posts
    			WHERE post_type = 'post' AND post_status = 'publish' AND post_date > '" . date('Y-m-d', strtotime('-3 days')) . "'
    			ORDER BY post_date DESC
    			";
    
      $posts = $wpdb->get_results($sql);
      $archives = array();
      foreach($posts as $post)
    	{
    		$key = strftime($splitformat, strtotime($post->post_date));
    		$archives[$key][] = $post;
    	}
      $output = $pre_HTML;
      	foreach($archives as $heading => $posts)
    	{
    		echo '<' . $headingtag . '>' . htmlentities($heading) . '</' . $headingtag . '>', "\n";
    		echo '<ul>', "\n";
    
    		foreach($posts as $post)
    		{
    			echo '	<li><a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a></li>', "\n";
    		}
    
    		echo '</ul>', "\n\n";
    	}
    ?>

    thanks

    Hello opblog, the above code helped me a lot, buy i want each date to be categories with post tittle as u. Pls help anyone?

    here we go……..
    <?php
    global $wpdb;
    $splitformat = ‘ %A %d %B %Y’;
    $sql = “SELECT ID, post_title, post_date
    FROM $wpdb->posts
    WHERE post_type = ‘post’ AND post_status = ‘publish’ AND post_date > ‘” . date(‘Y-m-d’, strtotime(‘-3000 days’)) . “‘
    ORDER BY post_date DESC
    “;
    $posts = $wpdb->get_results($sql);
    $archives = array();
    foreach($posts as $post)
    {
    $key = strftime($splitformat, strtotime($post->post_date));
    $archives[$key][] = $post;
    }
    $output = $pre_HTML;
    foreach($posts as $post) :
    $category = get_the_category();
    $cats[$category[0]->cat_ID] = $category[0]->cat_name;
    endforeach;
    $cats = array_flip($cats);

    foreach($archives as $heading => $posts)
    {
    echo ‘<‘ . $headingtag . ‘>’ . htmlentities($heading) . ‘</’ . $headingtag . ‘>’, “\n”;
    echo ‘

    ‘, “\n\n”;
    }
    ?>

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Group posts by Date on the front page?’ is closed to new replies.