Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to replace "published date" with "last updated" date
- This topic has 16 replies, 3 voices, and was last updated 9 years, 6 months ago by Fabio.
-
AuthorPosts
-
October 12, 2014 at 11:06 am #127584FabioParticipant
Hi there,
the title says it all. I keep updating my posts and it sucks that it shows a published date from 1 year ago or so.
I want to replace "published date" with "last updated" date so that when I update a post it shows:Last updated on October 12th, 2014 by Author
I was reading this article
http://www.wpbeginner.com/opinion/why-you-should-not-remove-dates-from-your-wordpress-blog-posts/and they say to use this code:
Last updated on <time datetime="<?php the_modified_time('Y-m-d'); ?>"><?php the_modified_time('F jS, Y'); ?></time>but I have no idea where to use it.
Any idea how to do this?Thanks
Fabiops- my site contains adult content NSFW (no porn, no nudity, just adult topics)
http://goo.gl/C3pfEAOctober 12, 2014 at 11:35 am #127585Brad DaltonParticipantOctober 13, 2014 at 7:25 am #127668FabioParticipantHi Brad,
I have copied both raw codes at the bottom of my functions.php file (I have tried on a test site first and not on the real one) and nothing happened. It did not show "last updated" at the top of the post.What's going on?
Thanks
FabioOctober 13, 2014 at 1:08 pm #127684FabioParticipantEleven 40 doesn't even display the words "published" usually. I have actually found other people on forums asking for help with this problem on Eleven 40 (I am using the old eleven 40, not the PRO one).
Any help please?October 13, 2014 at 11:13 pm #127717Brad DaltonParticipantWon't work if you use both code snippets.
Please only choose one method.
You will need to update the posts as well for the updated ( modified date ) to display.
All code snippets on my site are tested and work.
If it doesn't work for you then the problem is most likely at your end.
Some work is required on your behalf.
October 14, 2014 at 10:28 am #127786Brad DaltonParticipantFabio
Just tested the code and it works.
Here's the screen cast which may help http://www.youtube.com/watch?v=JjMEwtlSfB8
There's 2 steps required.
1st is to create the shortcode and the 2nd is to filter the post info and add the new shortcode so 2 snippets need to be pasted.
October 14, 2014 at 11:38 am #127790FabioParticipantHI Brad,
thanks for the video. I have pasted this code:add_filter( 'genesis_post_info', 'add_modified_date_post_info' ); function add_modified_date_post_info($post_info) { $post_info = 'Updated: [modified_date] by [post_author_posts_link] [post_comments] [post_edit]'; return $post_info; } function wordpress_modified_date_shortcode() { return get_the_modified_date(); } add_shortcode( 'modified_date', 'wordpress_modified_date_shortcode' );
at the bottom of my functions.php
I have updated the post, deleted the cache and hard-refreshed the page, but it's not working.
Maybe it only works on HTML5 themes and not on the old ones?Thanks
October 14, 2014 at 11:42 am #127791Sridhar KatakamParticipantOctober 14, 2014 at 12:25 pm #127798Brad DaltonParticipantDidn't test on the old themes running XHTML but you could be right.
Try the old code and see if it works with the shortcode http://my.studiopress.com/snippets/post-info/
October 15, 2014 at 3:00 pm #127919FabioParticipant@Sridhar
I have tried with that code on a website using News PRO and it didn't work.
Actually I have noticed you are using Eleven 40 on your website, so have you tried it there? Does it work?
I am using an old version of Eleven 40 - the one before the HTML5 update
@Brad
Sorry Brad what do you mean by:
Try the old code and see if it works with the shortcode http://my.studiopress.com/snippets/post-info/How do I need to edit/adapt that shortcode?
I have installed the same Eleven 40 on a test site. If you want I can post the credentials here and you can log in and see what's going on...
Thanks
October 15, 2014 at 10:41 pm #127954Brad DaltonParticipantI'm happy to login and fix the problem for you for a fee.
If you want this done, please send me your login details and i'll work out what the problem is.
October 16, 2014 at 3:16 pm #128053FabioParticipantHi Brad,
should I contact you through your site to have a quote?October 16, 2014 at 3:28 pm #128055Sridhar KatakamParticipantFabio, I do not have a copy of eleven40 (XHTML) theme to test.
I tested the code in http://www.studiopress.community/topic/how-to-replace-published-date-with-last-updated-date/#post-127790 in News Pro and Balance, a XHTML theme and it is working fine in both of them.
October 16, 2014 at 4:33 pm #128057FabioParticipantHi Sridhar,
that's strange now it seems to work on my test site too.
I will try on the blog and see what happens.October 20, 2014 at 6:14 pm #128516FabioParticipantOk super super weird:
It works on my test site:
http://testing.exclusiveskills.com/it doesn't work on my blog:
http://goo.gl/C3pfEAboth test site and blog have the same Eleven 40 version and same identical functions.php file.
Any idea where I should look for the issue?
October 24, 2014 at 6:09 pm #129018FabioParticipantI have copied
functions.php
home.php
and style.css
from my blog to the test site, so now the two sites have identical code, identical wordpress version and genesis version. And yet the test site shows the "last updated" and the blog doesn't.Is it possible that a plugin is interfering? I have some plugins installed on my blog which I don't have on the test site.
Is that a possible way to go to find the solution?October 26, 2014 at 3:04 pm #129315FabioParticipantThe problem is the "Genesis Simple Edits" plugin.
When I deactivated it, the "last updated" thing appeared.
Then I replaced this:
Last Updated: [modified_date] by [post_author_posts_link] [post_comments] [post_edit]in the post info section of the simple edits plugin and now it works 🙂
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.