This topic has 10 replies, 3 voices, and was last updated 7 years by Radu.

  • Author
  • #172312
     lopreg
    Participant

    Please, how can I show Last Modified date to tell readers and search engine bots when a content on my site was last updated?

    I will like to show something like “Last Updated: September 1, 2017” , in place of the actual publication date, as can be seen on the image below.

     

    Attachments:
    You must be logged in to view attached files.
    #172395
     Kieran_SQ
    Moderator

    Hi,

    Thanks for contacting us today, I’ve looked into your question and you’ll either need to do a lot of child theme customizations or use some sitewide code. The latter options is probably the best, please have a look at this article posted by WPbeginner on August 30th 2017 http://www.wpbeginner.com/wp-tutorials/display-the-last-updated-date-of-your-posts-in-wordpress/.

    They add the below code to the Child theme’s functions.php

    COPY CODE
    function wpb_last_updated_date( $content ) {
    $u_time = get_the_time('U'); 
    $u_modified_time = get_the_modified_time('U'); 
    if ($u_modified_time >= $u_time + 86400) { 
    $updated_date = get_the_modified_time('F jS, Y');
    $updated_time = get_the_modified_time('h:i a'); 
    $custom_content .= '<p class="last-updated">Last updated on '. $updated_date . ' at '. $updated_time .'</p>';  
    } 
     
        $custom_content .= $content;
        return $custom_content;
    }
    add_filter( 'the_content', 'wpb_last_updated_date' );

    You can use the below CSS class to style your element to suit your needs

    COPY CODE
    .last-updated {
    } 

    Hope this helps,

    Kieran.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    #172474
     lopreg
    Participant

    Hello KieranSQ

    I added the suggested code to the Child theme’s functions.php but the output was on Pages and not posts. Please, how can I make this work on Post pages only?

    #172483
     Kieran_SQ
    Moderator

    Hi,

    You do not appear to be using the post meta on your single posts, try enabling this to see if the above code works.

    You can go to Theme Options > Blog > Scroll to: Meta settings to enable date meta for single posts

    See here for example: https://www.campusportalng.com/education/post-utme-news-updates/27098/.

    Thanks,

    Kieran.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    #172548
     lopreg
    Participant

    Hi KieranSQ

    I had actually disabled Meta for only that particular post. I have re-enabled it now and the above code still does not work. Please, check again

    #172549
     lopreg
    Participant
    This reply has been set as private.
    #172550
     Kieran_SQ
    Moderator

    Okay, I am going to ask my colleague @Radu look at this for you as this should work – they may well have better ideas on how to achieve this.

    Please can you update the post with some login credentials, they’ll be in touch with you on Monday or Tuesday.

    Thanks for your patience,

    Kieran.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    #172559
     lopreg
    Participant

    I have already attached the login credential to my last response. I will be waiting for their response then. Thanks

    #172682
     Radu
    Moderator

    Hi,

    Revert back all of those changes/snippets and use this instead: https://pastebin.com/raw/k72fn2X7

    Just copy that code to wp-content/themes/kleo-child/functions.php

    NOTE: Child theme needs to be installed and activated.

    The Last updated date will be displayed only on the post pages somewhere else the normal.

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Ticket solution
    #172706
     lopreg
    Participant

    It worked! 🙂 Thanks a lot @Radu and @KieranSQ

    #172758
     Radu
    Moderator

    You’re welcome

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 11 posts - 1 through 11 (of 11 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?