Support » Themes and Templates » adding the date to a wp_get_archives list

  • I’m using <?php wp_get_archives(‘type=postbypost&format=html’); ?> to list the titles of my posts. But I’d like the format to be: “Title (Date of post)”

    Is there any way to get it to include something like “(<?php the_time(‘F jS, Y’) ?>)” after the post title?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Does anyone know how to do this?

    I’m also looking for something like this. Anybody?



    This was not a full fix but I at least was able to format the date in a slightly more pleasing way by truncating the time off it:

    in wp-includes folder find templates-functions-general.php and loook for the
    } elseif ( 'postbypost' == $type ) { section which formates that post by post archives results.

    This is what I changed it to (I don’t remember how much of it I changed so compare to your file:

    =====START OF CODE=====

    } elseif ( ‘postbypost’ == $type ) {

    $arcresults = $wpdb->get_results(“SELECT * FROM $wpdb->posts WHERE post_date < ‘$now’ AND post_status = ‘publish’ ORDER BY post_date DESC” . $limit);

    if ( $arcresults ) {
    foreach ( $arcresults as $arcresult ) {
    if ( $arcresult->post_date != ‘0000-00-00 00:00:00’ ) {

    $shortdate = $arcresult->post_date;
    $dateresults = $wpdb->get_results(“SELECT DISTINCT YEAR(post_date) AS ‘year’, MONTH(post_date) AS ‘month’, DAYOFMONTH(post_date) AS ‘dayofmonth’ FROM $wpdb->posts WHERE post_date = ‘$shortdate'” . $limit);

    $date = sprintf(“%02d-%02d-%d”, $dateresults->month, $dateresults->dayofmonth, $dateresults->year);

    $url = get_permalink($arcresult);
    $arc_title = $arcresult->post_title;
    if ( $arc_title )
    $text = strip_tags($arc_title, $date);
    $text = $arcresult->post_title . “title”;
    echo get_archives_link($url, $text . ” (” . substr($shortdate, 0, -9) . “)”, $format, $before, $after);

    ====END OF CODE====

    The most important part is the substr($shortdate, 0, -9) near the end since that shaves the last 9 digits off the results getting rid of the time. Now my archives look like this: which is not what I wanted but is acceptable.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘adding the date to a wp_get_archives list’ is closed to new replies.