WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Customizing date display

[Resolved] Customizing date display

  • I want to display month only in the last post of the month and every post to have the day. LIke:

    Feb 19: Title
    12: Title
    05: Title
    01: Title
    Mar 23: Title
    17: Title
    so on…

    Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Before your loop put this:

    <?php
    $last_date='';
    ?>

    Then inside your loop put

    <?php
    $current_post_ym = get_the_time('Ym');
    if ( $last_date != $current_post_ym ) {
      $last_date = $current_post_ym;
      $display_date = get_the_time('M d');
    } else {
      $display_date = get_the_time('d');
    }
    ?>
    <p><?php echo $display_date .':'; ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>

    Works great! Thanks Michael!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Customizing date display’ is closed to new replies.
Skip to toolbar