[resolved] Day of Week archive output (2 posts)

  1. shacker
    Posted 7 years ago #

    Hi -

    A client would like to display a horizontal list:

    Sun Mon Tues Wed Thurs Fri Sat

    each day would link to a page showing posts made last Monday, Tuesday, etc.


    does not get you there - that links to archive pages containing a whole week worth of information.


    Has almost no optional flags - certainly nothing to get us close to this functionality. I've searched plugin databases for "week" and "weekly" but have come up empty.

    Would I be better off writing this functionality from scratch, or this there a template tag I'm overlooking, or is there a lightweight calendar plugin taht can be made to do this? Thanks.

  2. shacker
    Posted 7 years ago #

    OK, for the archives - here's what I came up with to accomplish this. Unfortunately, this simple code will also link to days that had no news. wp_get_archives() would not have that problem, but unfortunately it won't work for this need.

    <?php // Calculate day and date values for the preceding week,
     // counting back from now. There are 86400 seconds in a day.
    $counter = 6;
    while ( $counter >= 0 ) {
      $timestamp = mktime()-$counter*86400;
      $agodate = date('Y/m/d',$timestamp);
      $agoday = date('D',$timestamp);
      echo "<li><a href=\"";
      echo "/$agodate\">$agoday</li>";
      $counter -= 1;

Topic Closed

This topic has been closed to new replies.

About this Topic