[Resolved] Showing "last updated on" date certain times, and "posted on" date at others.

Home Forums Support [Resolved] Showing "last updated on" date certain times, and "posted on" date at others.

Home Forums Support Showing "last updated on" date certain times, and "posted on" date at others.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #618876
    Jay

    I have a site running Genesis that I’m switching to GeneratePress. There’s some stuff in my old child theme’s functions.php that I’m trying to bring over to GP using the Code Snippets plugin.

    One thing I previously had was some code to show the “last updated” date on single post pages, but show the “posted on” date on other types of pages. This code made that happen…

    add_filter( ‘genesis_post_info’, ‘sp_post_info_filter’ );
    function sp_post_info_filter($post_info) {
    if ( is_singular( ‘post’ ) )
    $post_info = ‘Last Updated on [post_modified_date]’;
    if ( is_archive( ) )
    $post_info = ‘Posted on [post_date]’;
    if ( is_home( ) )
    $post_info = ‘Posted on [post_date]’;
    if ( is_search( ) )
    $post_info = ‘Posted on [post_date]’;
    return $post_info;
    }

    How do I adapt this to GP? I already changed genesis_post_info to generate_post_date_output which seems to be correct, but now instead of the dates I just have the actual text of “[post_modified_date]” or “[post_date]” displaying.

    Any ideas?

    Thanks.

    #618893
    Leo
    Staff
    Customer Support

    Hi there,

    Would this help?
    https://docs.generatepress.com/article/show-the-updated-post-date/

    You just have to adjust the CSS a bit to target certain pages

    Let me know 🙂

    #618913
    Jay

    Thanks for the fast reply! This method definitely seems easier, but is there any difference to the end result? Specifically, the method I’ve been using (as seen in my first post) has allowed Google to display the last modified date in their search results as the date shown along with each of my posts.

    Would this css method do the same?

    #619405
    Tom
    Lead Developer
    Lead Developer

    Absolutely – Google will pick up the updated date no matter what.

    We can even adjust the CSS to only show the updated date on single posts if that works better for you?

    #619468
    Jay

    Thanks Tom! Yes, I’m trying to only show the last updated date on single posts, and then the original date it was first posted on all archive/search/category pages.

    #619585
    Leo
    Staff
    Customer Support

    Try this:

    .single .posted-on .updated {
        display: inline-block;
    }
    
    .single .posted-on .updated + .entry-date {
        display: none;
    }
    #619658
    Jay

    Thanks! That worked perfectly. The only other thing I need to do here is have the dates not be links… just plain text instead.

    #619832
    Leo
    Staff
    Customer Support
    #620329
    Jay

    Thanks!

    #620425
    Leo
    Staff
    Customer Support

    No problem 🙂

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