Site logo

Archived topic

How to display Last Updated date on pages and posts

21 replies · Started by Amit on January 31, 2018

Viewing posts 1–15 of 22

In many results from Google, it's visible that people are using Last modified date. I am also thinking of adding the same to my posts and pages as well. Pages as of now don't display any dates so I require a separate code for displaying on pages and separate code for posts to display last modified date like this
https://www.coffeemakersadvisor.com/best-keurig-coffee-maker-reviews/
https://coffeemakerpicks.com/.

One more thing, the front is also a page so don't want to display date on the front page.

You can tell your posts to display the updated date like this: https://generatepress.com/forums/topic/post-updated-date/#post-470725

You can add the date to pages like this:

add_action( 'generate_after_entry_header', 'tu_page_meta' );
function tu_page_meta() {
    if ( is_singular( 'page' ) ) : ?>
        <div class="entry-meta">
            <?php generate_posted_on(); ?>
        </div><!-- .entry-meta -->
    <?php endif;
}

Into which file should I place this code?

And what if I want to display the Last updated date on pages only?

I did added the code to the child theme in functions.php. The code didn't worked but it removed the 'published date'.

Did you remove the code from the site? I'm seeing the published date still.

Let me know :)

Yes I removed as it didn't worked!
Now I added again for your check.

Yes, now it displays the date. One addon, I want to display 'Last Modified' before the date.
Also, where should I insert the above provided code for displaying date in pages.

Works perfectly....thanks Tom for the quick support. One of my favorite theme so far....

You're very welcome! :)

Hey Tom, how can I avoid displaying date on home page?

This archived topic is closed to new replies.