Home › Forums › Pro Support › Created date on first publish, updated date on update after
- This topic has 11 replies, 2 voices, and was last updated 4 years ago by
Tom.
-
AuthorPosts
-
June 11, 2019 at 2:16 pm #9834
Daniel
ParticipantHi,
I want to show the created or updated date on my posts. I want the created date the first time a post is published and after only showing updated date.
In the Meta section i see only Include date checkbox which from my understanding is the creation date.
The first time I publish I want to be able to show “Created on june 1, 2019” and one week later, if I’m updating the post, I want to show “Updated on june 7, 2019”.
Is there any way to do that? If not, will you consider to add that feature on your roadmap?
Thank you,
June 13, 2019 at 3:46 pm #9857Tom
KeymasterHi there,
This might help: https://wpshowposts.com/support/topic/updated-date-meta-from-generatepress/#post-3920
Let me know 🙂
June 13, 2019 at 5:07 pm #9860Daniel
ParticipantHi Tom,
Concerning the date, it seem to work, I do see the last updated date for the posts.
What should I do in order to prefix the date with the text “Published on” vs “Updated on” depending on if it is the first time publish vs an update?
June 14, 2019 at 5:14 pm #9867Tom
KeymasterGive this a shot:
.wp-show-posts-entry-date:before { content: "Created on "; } .wp-show-posts-updated:before { content: "Updated on "; }
June 15, 2019 at 5:21 am #9871Daniel
ParticipantI created a new post and I see “Updated on ” + date, not “Created on ” + date. (In French, “Publié le ” + “Mis à jour le “)
Here is all I have done trying to make it work.
I created the following code snippet:
add_filter( 'wpsp_date_output', 'tu_wpsp_updated_date_first' ); function tu_wpsp_updated_date_first() { $time_string = ''; if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string .= '<time class="wp-show-posts-updated" datetime="%3$s" itemprop="dateModified">%4$s</time>'; } $time_string .= '<time class="wp-show-posts-entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>'; $time_string = sprintf( $time_string, esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), esc_attr( get_the_modified_date( 'c' ) ), esc_html( get_the_modified_date() ) ); // If our date is enabled, show it $output = sprintf( '<span class="wp-show-posts-posted-on wp-show-posts-meta"> <a href="%1$s" title="%2$s" rel="bookmark">%3$s</a> </span>', esc_url( get_permalink() ), esc_attr( get_the_time() ), $time_string ); return $output; }
I added the following custom CSS:
/* Created after updated date */ .wp-show-posts-updated { display: inline-block; } .wp-show-posts-updated + .wp-show-posts-entry-date { display: none; } /* Created after updated date label */ .wp-show-posts-entry-date:before { content: "Publié le "; } .wp-show-posts-updated:before { content: "Mis à jour le "; }
I commented any previous CSS customization attempt.
June 17, 2019 at 4:22 pm #9900Tom
KeymasterHmm, WordPress itself decides whether a post is new or updated. Was this a brand new post that hasn’t been published/saved as a draft?
June 17, 2019 at 5:49 pm #9901Daniel
ParticipantIt was a brand new published post. wirecutter.com use WordPress and they seem able to sort between “published on” vs “updated on”.
I guess I will have to live with “updated on” all of the time instead of “published on” + “updated on” if it require too much work in order to achieve.
June 18, 2019 at 4:32 pm #9919Tom
KeymasterCan you link me to a page which has a post that’s never been updated?
June 18, 2019 at 5:05 pm #9922Daniel
Participanthttps://www.optionparent.com/, the post named “Meilleurs tire-laits électriques” below the section label “Alimentation”
I’ve just published this post for the first time 5 minutes ago, i will not update it in the short term.June 19, 2019 at 4:29 pm #9945Tom
KeymasterStrange – I’ll do some tests on this and will update you 🙂
September 14, 2019 at 7:30 am #11117Daniel
ParticipantThe problem has not reappeared since the opening of the ticket so I consider it to be a non-recurring intermittent problem that is unlikely to recur easily so we can close this post.
September 18, 2019 at 4:47 pm #11184Tom
KeymasterThanks for letting me know 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.