Site logo

[Resolved] Updated date not showing after CSS added

Home Forums Support [Resolved] Updated date not showing after CSS added

Home Forums Support Updated date not showing after CSS added

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2448412
    Jessica

    Hi! I’m wondering if it’s possible for both (1) a post’s updated date to be exclusively present in the html; and (2) both the original published date and the updated date to be visible at the top of every post.

    I first tried adding this CSS & clearing my server’s cache, with zero results on my site:

    /* Display updated date */
    .posted-on .updated {
    display: inline-block;
    margin-right: 1em;
    }
    /*Add date prefixes */
    .posted-on .updated:before {
    content: ‘Updated: ‘;
    }
    .posted-on .entry-date:before {
    content: ‘Published: ‘;
    }

    (I do have header elements running, for Google Analytics and Google Tag Manager click-thru tracking; would that possibly interfere?)

    After that, I found the filter generate_post_date_show_updated_only for hiding the published date in the html, which worked well to show only the updated date in each post.

    Let me know if I might be able to add some other code to get both dates visible in my posts;
    Thanks so much for the fantastic support!!!

    #2448945
    David
    Staff
    Customer Support

    Hi there,

    i am a little confuse ( which is quite common for me lol ).
    As you cannot show both dates ( published and updated ) on the front end, but only have the updated date in the HTML. For them both to be visible they both have to be in the HTML.
    Are you wanting both dates to be visible on your site, but have google always use the updated?

    #2449394
    Jessica

    Ha, thanks for the humor.

    “Are you wanting both dates to be visible on your site, but have google always use the updated?”

    That was my original idea;

    But after some research, I think it’s optimal to prioritize the updated date for SEO purposes; to make sure each post is appearing fresh, and only update when I have substantive changes.

    And I assume it’s simpler; that’s not gonna involve some complicated work-around to try to make Google not show the publish date in serps.

    Thank you! Now I’m just curious why I can’t get other CSS to work to change a WP table header color; will open a new thread about that!

    #2450033
    David
    Staff
    Customer Support

    You can add the PHP Snippet provided here:

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

    That will display only a single date, either the published ( when there has been no updates ) or the updated date.

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