[Resolved] How to display Last Updated date on pages and posts

Home Forums Support [Resolved] How to display Last Updated date on pages and posts

Home Forums Support How to display Last Updated date on pages and posts

Viewing 15 posts - 1 through 15 (of 22 total)
  • Author
    Posts
  • #485024
    Amit

    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.

    #485093
    Tom
    Lead Developer
    Lead Developer

    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;
    }
    #485131
    Amit

    Into which file should I place this code?

    #485132
    Amit

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

    #485140
    Amit

    I used the code at https://generatepress.com/forums/topic/post-updated-date/#post-470725. It removed even the already appearing date.

    #485553
    Leo
    Staff
    Customer Support

    Tom’s code can be added like using one of the methods here: https://docs.generatepress.com/article/adding-php/

    #486075
    Amit

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

    #486125
    Tom
    Lead Developer
    Lead Developer

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

    Let me know ๐Ÿ™‚

    #486199
    Amit

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

    #486594
    Tom
    Lead Developer
    Lead Developer

    Ah, add this CSS:

    .posted-on .updated {
        display: inline;
    }

    As for pages, is this snippet added?: https://generatepress.com/forums/topic/how-to-display-last-updated-date-on-pages-and-posts/#post-485093

    #486895
    Amit

    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.

    #486915
    Tom
    Lead Developer
    Lead Developer

    Add this:

    .posted-on .updated:before {
        content: "Last Updated: ";
    }

    You should add the other code snippet the same as any other snippet: https://docs.generatepress.com/article/adding-php/

    #486939
    Amit

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

    #486940
    Tom
    Lead Developer
    Lead Developer

    You’re very welcome! ๐Ÿ™‚

    #488236
    Amit

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

Viewing 15 posts - 1 through 15 (of 22 total)
  • You must be logged in to reply to this topic.