[Resolved] Want to show updated date in place of published on posts and google results

Home Forums Support [Resolved] Want to show updated date in place of published on posts and google results

Home Forums Support Want to show updated date in place of published on posts and google results

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1570209
    Bryan

    I am using a Marketer theme but there is no option to show the updated date of the post instead of the published date on the posts and google search results.

    I am a newbie so if you are referring me to certain changes in the theme files kindly guide me.

    #1570221
    David
    Staff
    Customer Support

    Hi there,

    it requires a little PHP Snippet to be added to your site.
    This is the filter required for reference:

    https://docs.generatepress.com/article/generate_post_date_show_updated_only/

    Options for adding PHP to your site is covered here in detail:

    https://docs.generatepress.com/article/adding-php/

    Quick snapshot of how to for that – there are two options:

    Option 1. If you’re using a Child theme then copy the code provided ie:

    add_filter( ‘generate_post_date_show_updated_only’, ‘__return_true’ );

    And paste into your child themes functions.php file.

    Option 2. If you’re not using a child theme then install the Code Snippets plugin:

    https://en-ca.wordpress.org/plugins/code-snippets/

    Once enabled Dashboard > Snippets > New.
    Paste the code in there and save it. Leave all other settings as default.

    #1570568
    Bryan

    OK, I get it. Very nice explanation.

    And it’s working. I installed a plugin code snippets then add the provided code here.

    Next help I want that it replaces the published date but I want the text to appear like ‘Last updated on’ so please help me with that

    #1570728
    David
    Staff
    Customer Support

    You can add this snippet:

    add_filter( 'generate_post_date_output','tu_add_to_post_date' );
    function tu_add_to_post_date( $output ) {
        return '<span>Last updated: </span>' . $output;
    }
    #1571904
    Bryan

    First of all, thank you so much, David.

    Secondly, will it show in the Google search results?

    #1572146
    Elvin
    Staff
    Customer Support

    Secondly, will it show in the Google search results?

    It will but not immediately. Google bots will have to recrawl your site with the updated settings first.

    You can ask Google to recrawl your site if you’re worried that it might take too long.
    https://developers.google.com/search/docs/advanced/crawling/ask-google-to-recrawl

    A wise man once said:
    "Have you cleared your cache?"

    #1572552
    Bryan

    Thank you so much. You guys are awesome.

    #1572554
    Elvin
    Staff
    Customer Support

    Thank you so much. You guys are awesome.

    No problem. Glad to be of any help. 🙂

    A wise man once said:
    "Have you cleared your cache?"

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