Custom WordPress Theme: Publish Date and Display Date for posts right beside each other

What’s currently happening is that for posts that have an ‘update’ time, the original publish and editor dates are rendering side by side (with no extra information in between, or even a space for that matter), and I’m not entirely sure where I should look to fix this. I need guidance in terms of which files to look in for this output code, or, if possible, some other manner in which to add a word or two in between the two dates. The theme is based off of _S – which explains why I do not know where my desired page is, and this problem persists in any area of the theme where you can see the dates (Blog, Search Results, actual posts themselves).

I could hide one of the dates with CSS – but I’d definitely want to show the most recent update date, and that would leave me with the dilemma of making complex and unnecessary CSS to hide dates which could be handled in a much better way (I’m thinking of setting link display to none, then :last-child’s display to true, but browser compatability would be hit, and it doesn’t seem very prfoessional to me).

Demo Of Problem

Solutions Collecting From Web of "Custom WordPress Theme: Publish Date and Display Date for posts right beside each other"

Special thank you to RachieVee for getting the ball rolling with their comment.

I figured out how to do this, so I thought I might as well document it for future reference by others. On a side note, this only pertains to the _S theme, or any theme based off of that starting template.

Alright, so it takes about 5 minutes to fix this “double date” – after checking the content.php file, I found <?php my_underscores_theme_name_posted_on(); ?> where the meta output was for the date and time information. After doing a little digging, I ran into the my_underscores_theme_name.pot file -and on lines 257 to 260, the following information was written:

#: inc/template-tags.php:82
msgctxt "post date"
msgid "Posted on %s"
msgstr ""

I deduced that this was what I needed, yet it was still too limiting. So I went into the php file referenced (inc/template-tags.php) at line 82, and changed it to look like so (for your case, replace league_of_legends_rift with whatever your theme name is.):

if ( ! function_exists( 'league_of_legends_rift_posted_on' ) ) :
 * Prints HTML with meta information for the current post-date/time and author.
function league_of_legends_rift_posted_on() {
    $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
    $time_string = $time_string;
    if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
        $time_string2 = ', last updated on ';
        $time_string2 .= '<time class="updated" datetime="%1$s">%2$s</time>';

    $time_string = sprintf( $time_string,
        esc_attr( get_the_date( 'c' ) ),
        esc_html( get_the_date() )
    $time_string2 = sprintf( $time_string2,
        esc_attr( get_the_modified_date( 'c' ) ),
        esc_html( get_the_modified_date() )

    $posted_on = sprintf(
        _x( 'Posted on %s', 'post date', 'league-of-legends-rift' ),
        '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'.$time_string2

    $byline = sprintf(
        _x( 'by %s', 'post author', 'league-of-legends-rift' ),
        '<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'

    echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>';


This it looked slightly different before, a lot more condensed with one variable ($time_string) which would have your original publish date and your update date appended to each other. I used the logic already present and introduced a second variable, $time_string2 which I used to store the phrase and information for the updated date. Then I modified the $posted_on to include this new variable and the formatting that I wanted – mind you, to edit this appended output you’ll now have to do it from this php file, rather then the “.pot” file I referenced earlier.

Hope this helped you as much as it helped me!