This post is all about showing the last update date or last modified date in your post, and this technique will work in any theme, including GeneratePress Premium.
Php Codes to Show Updated or modified date in Post
Copy the below code and paste it into your function.php file.
// By Web Insights
add_filter( 'generate_post_date_output', function( $output, $time_string ) {
$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Published on: %2$s</time>';
if ( get_the_date() !== get_the_modified_date() ) {
$time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Last Updated on: %4$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() )
);
return sprintf( '<span class="posted-on">%s</span> ',
$time_string
);
}, 10, 2 );
Let me know if you have any doubts. Use the comment section it’s free!
Hi,
I want to give you 5 star but by mistake I clicked on 3.5 star.
Your content is very helpful.
No problem! I like your honesty.
HI ANAND
HOW ARE YOU,
PLEASE MAKE A VIDEO OF AUTHOR BOX AND SHARING CARING.
I WANT TO PURCHASE GP PRMIUM PLUGIN ALSO.
Does it work in Newspaper theme?
I do not think so.
If I buy any generatepress Premium from your website for lifetime will I get all the support from generatepress as I have bought this. Please reply
Yes, As the theme will be activated with the license key!
Thank you much, Brother.
Do you know some people are giving the same code?
But we know these codes are created by you.
We all are with you and we hope you will be succeded.
PLEASE Keep up this GREATE Work.
Thank you so much & LOVE YOU Brother.
I know many YouTubers did the same.
They copied my code, and even they did not give me credit.
You are the best bro …yours explanations in every video is very easy to undersatnd and it helps me a lot.
Glad You Liked! Keep Vsiting.
Does it work in the Jnews theme?
Do not think So!
I am from Bangladesh. Thanks for sharing , this was a very helpful video. But when I apply, it shows the end of the content. please tell me the solution.
bhai mene ye code paste kia but shi se work nhi kia meri website me html bi sath me show kr rha h
this code is note working..
this show result like this
Published on: January 10, 2022 by admin
I tried to give stars but it is not happening so. I tried with 5 star then 1 star still I am facing the issue. I never gave any stars before on ur site. I guess the stars rating are not working
I pasted the same code as you per your guidance. but it didn’t work?
code not working totally fake information
Thanks!
This code is not working in the post-template created from Elementor. Please tell me the solution by doing this. I will wait for your reply.
I use GeneratePress theme
I won’t work for elementor based archives.