Date Posting Twice
-
When I make a post the date shows up twice. How do I fix this?
The page I need help with: [log in to see the link]
-
Hi, as you don’t have a live version for us to look at, which theme are you using? May be able to diagnose the issue further that way as it is most likely an issue with the theme code.
First – that link your provided is to the localhost on your computer. No one can open your site when you have it installed locally on your computer.
What changes have you made lately, before the date display problem.
I need a lot more information before I can even begin to help your.
- WP release number
- Theme name
- what changes have been made before the problem began
- everything you can tell me about the site
Sorry! I am really new to this to please work with me here.
I am running WP 5.1.1
I am using the theme – Massage Clean
I now see when I make a change/edit to the post that is when the date shows up twice.
Perhaps it is showing the date the post was first published and also the date the post was last updated.
Are the dates identical?
Is the time showing along with the date? Is the date and time the same or different?
I am wondering that. ANd I wonder if when I make this ‘live’, it won’t show? The time doesn’t change, just double enters the date.
I just installed the Massage Clean theme and I’m seeing dates like this:
March 18, 2019March 21, 2019That first date is the date the post was published and the second date is when it was last updated.
Are you seeing the same thing – two dates run together?
Here’s what the source shows for the time fields:
<time class="entry-date published" datetime="2019-03-18T01:24:05-05:00">March 18, 2019</time><time class="updated" datetime="2019-03-21T23:53:55-05:00">March 21, 2019</time>Note the class names, the first is entry-date published’. The second is just “updated”.
On my system, the dates are date published and date updated.
Pull up one of your pages. Highlight just one of the date lines. Right click on the highlighted text and select View Source.
Copy what you see and paste it into a reply. Let me see what is there.
Tferral – I am seeing the same thing!
When I highlight-right click I do not have the option to ‘View Source’
Have you a program with which you can look at and edit one of the files in the theme?
I think I found the spot where the date line is created when viewing an index page.
It is in the file: wp-content/themes/massage-clean/inc/template-tags.php on line 42. It looks like this:
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>;<time class="updated" datetime="%3$s">%4$s</time>';Change it to:
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time> <time class="updated" datetime="%3$s">%4$s</time>';The change is to insert after the first “</time>”
&npsp is a way of coding in space so that it does not get removed as simple spaces can be in some situations.
Save the file and go look at your index page. There sould be a space between the dates.
Let me know what you see.
-
This reply was modified 7 years, 1 month ago by
tferral. Reason: removed duplicate text at bottom of reply
Sorry – the menu item will be View Selection Source for highlighted text.
EDIT – that is for Firefox I don’t think Chrome has the same option.
If you are using Chrome, click on a blank place on the page and then right click and select View page source.
Then search for the word March in the source and then hit F3 until you find the line with the two dates on it.
You’ll see that the classes are different.
Edit – the line will begin with
<div class="post-date"><span class="screen-reader-text"></span> <a href=How’s it going?
I made changes to two files and now I see, for example:
Published: March 18, 2019 1:24 AM Updated: March 21, 2019 11:53 PM
On the index page and no the single post page.
In file wp-content\themes\massage-clean\content-single.php
I changed the division with class=’postmeta to:
<div class="postmeta"> <div class="post-date"><span style="font-weight:bold;">Published: </span><?php echo get_the_date(); ?> <?php echo get_the_time(); ?> <time class="updated"> <span style="font-weight:bold;">Updated: </span> <?php echo get_the_modified_date(); echo get_the_modified_time(). ' '; ?></time> </div><!-- post-date --> <div class="post-comment"> | <a href="<?php comments_link(); ?>"><?php comments_number(); ?></a></div> <div class="clear"></div> </div><!-- postmeta -->In the file wp-content\themes\massage-clean\inc\template-tags.php it changed the function named massage_clean_time_link() to:
/** * Gets a nicely formatted string for the published date. */ function massage_clean_time_link() { $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">Published: %2$s</time> <time class="updated" datetime="%3$s"> Updated: %4$s</time>'; } $time_string = sprintf( $time_string, get_the_date( DATE_W3C ), get_the_date(), get_the_modified_date( DATE_W3C ), get_the_modified_date() ); // Wrap the time string in a link, and preface it with 'Posted on'. return sprintf( /* translators: %s: post date */ __( '<span class="screen-reader-text"></span> %s', 'massage-clean' ), '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>' ); }These are quick and perhaps dirty modifications but they work.
You need to contact the author of the theme and explain what is happening and give them the updates I made.
You need these changes made by the author. If you just modify the files yourself, an update to the theme could, likely wound eliminate the changes.
Basically tell them that they need to produce the date and time to look like this:
Published: March 18, 2019 1:24 AM Updated: March 21, 2019 11:53 PM
On both the single post display and the index display.
I’m here if you need more help.
I just looked at the support forum for that theme and it is empty.
If you go to https://wordpress.org/themes/massage-clean/ and click the preview button, you’ll see the formatting problem right there for the world to see:
October 17, 2008September 9, 2011
They don’t have a space between dates and the time isn’t show for either date.
The lack of a space is a bug and should be reported. Since I’m not using the theme, it would be best for you to contact them.
Here is their contact page https://flythemes.net/contact/
Are you using the free theme or the Pro version which you paid for?
Regardless, they should fix the space problem and format the line like I showed you in my previous reply:
Published: March 18, 2019 1:24 AM Updated: March 21, 2019 11:53 PM
Good luck
Hang off on those changes, I’ve found problem in the code I showed for the file
wp-content\themes\massage-clean\inc\template-tags.phpI’ll post the corrected code in a few minutes.
I’ve tested the code below and it works fine with Version: 1.1 of the Massage Clean theme.
It will put a space between the dates, adds the times to the dates, add Published: and Updated:, and makes them bold.
Here’s the code I changed in the wp-content\themes\massage-clean\inc\template-tags.php
I replaced this entire function to make it easier to change:
function massage_clean_time_link() { $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"><span style="font-weight: bold;">Published:</span> %2$s</time><time class="updated" datetime="%3$s"> <span style="font-weight: bold;">Udpated:</span> %4$s %5$s</time>'; } $time_string = sprintf( $time_string, get_the_date( DATE_W3C ), get_the_date() . ' ' . get_the_Time(), get_the_modified_date( DATE_W3C ), get_the_modified_date(), get_the_modified_time() ); // Wrap the time string in a link, and preface it with 'Posted on'. return sprintf( /* translators: %s: post date */ __( '<span class="screen-reader-text"></span> %s', 'massage-clean' ), '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>' ); }Here are the changes for wp-content\themes\massage-clean\content-single.phpfile. I replaced an entire <div> tag to make it easier to make the changes:
<div class="postmeta"> <div class="post-date"><span style="font-weight:bold;">Published: </span><?php echo get_the_date(); ?> <?php echo get_the_time(); ?> <time class="updated"> <span style="font-weight:bold;">Updated: </span> <?php echo get_the_modified_date(); echo ' '; echo get_the_modified_time(). ' '; ?></time> </div><!-- post-date --> <div class="post-comment"> | <a href="<?php comments_link(); ?>"><?php comments_number(); ?></a></div> <div class="clear"></div> </div><!-- postmeta -->-
This reply was modified 7 years, 1 month ago by
tferral. Reason: corrected the name of the theme
If you want to hide the updated post date without modifying any code you can just use the following CSS in Appearance->Customize->Additional CSS
.postmeta .updated { display: none; }
The topic ‘Date Posting Twice’ is closed to new replies.