0

I'm the webmaster of a grad school student group. We have a WP site I took over from the last webmaster, who took over from the person before, etc. I just started over the summer. Blog posts are showing two dates next to each other instead of one.

For example, the latest post shows "August 21, 2023September 8, 2023" as the date. My guess is these are the dates of the original post and when it was updated.

If I toggle the date off in Blog Single Settings, it removes both. I've looked over different settings and can't figure out where this is coming from. Does anyone have an idea of where I could look to change this?

1 Answer 1

0

Some WordPress templates show the published and updated dates side by side. For example, https://bootscore.me/ does this and separates the two with a forward slash.

If you want to fix this then in the child theme you override the date function. So with bootScore in particular you would take this function:

function bootscore_date()
{
  $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
  if (get_the_time('U') !== get_the_modified_time('U')) {
    $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time> <span class="time-updated-separator">/</span> <time class="updated" datetime="%3$s">%4$s</time>';
  }

  $time_string = sprintf(
    $time_string,
    esc_attr(get_the_date(DATE_W3C)),
    esc_html(get_the_date()),
    esc_attr(get_the_modified_date(DATE_W3C)),
    esc_html(get_the_modified_date())
  );

  $posted_on = sprintf(
  /* translators: %s: post date. */
    '%s',
    '<span rel="bookmark">' . $time_string . '</span>'
  );

  echo '<span class="posted-on">' . $posted_on . '</span>'; // WPCS: XSS OK.
}

and redefine it in your functions.php file as this:

function bootscore_date()
{
  $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';

  $time_string = sprintf(
    $time_string,
    esc_attr(get_the_date(DATE_W3C)),
    esc_html(get_the_date()),
    esc_attr(get_the_modified_date(DATE_W3C)),
    esc_html(get_the_modified_date())
  );

  $posted_on = sprintf(
    /* translators: %s: post date. */
    '%s',
    '<span rel="bookmark">' . $time_string . '</span>'
  );

  echo '<span class="posted-on">' . $posted_on . '</span>'; // WPCS: XSS OK.

}

which will remove the updated date and only keep the published date.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.