Site logo

[Resolved] Add ‘publish date’ to specific pages

Home Forums Support [Resolved] Add ‘publish date’ to specific pages

Home Forums Support Add ‘publish date’ to specific pages

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #2116568
    Kia

    Hi GP Team,

    I would like to display the publish dates on specific pages. is there a way I can add the date the page was published (like in a blog post) to just a handful of pages?

    Many thanks.

    #2116840
    David
    Staff
    Customer Support

    Hi there,

    where within the page do you want to show the date ?

    #2116950
    Kia

    Hi David,

    Just below the title. Like in a blog post (example)

    Thanks.

    #2117116
    David
    Staff
    Customer Support

    Try this:

    1. Create a new Hook Element in Appearance > Elements:

    https://docs.generatepress.com/article/hooks-element-overview/

    2. Add this code to the Element text area:

    <?php echo get_the_date(); ?>

    3. Set the hook to: generate_after_entry_header

    4. Check the Execute PHP option

    5. Set the Display Rule Locations to pages you want it to appear on:

    #2117137
    Kia

    Works a treat! Thank you so much! 👊

    #2117652
    David
    Staff
    Customer Support

    Glad to hear that!

    #2535095
    Ravi Saive

    @David,

    how to add the text ‘Last Updated‘ to date and align it to the right side?

    #2535098
    Fernando
    Customer Support

    Hi Ravi,

    For reference, can you provide the a to where you want to add this text?

    #2535119
    Ravi Saive

    I want to show the text ‘Last Updated’ with the date on specific pages on the right side…

    Here is the screenshot – https://i.postimg.cc/vT7sYxDD/Screenshot-2023-02-16-13-24-48.pngv

    #2535129
    Fernando
    Customer Support

    Can you share the link to that page?

    If you want, you can also start a new topic so you can use the Private Information field.

    #2535139
    Ravi Saive

    @Fernando,

    Here is the page link

    #2535153
    Derek

    Keen to do the same. I would like a “date published” and a “date modified” at the tops of each post.

    #2535155
    Fernando
    Customer Support

    Hi Derek,

    Are you referring to Posts or Pages? This topic is for showing the publish date on pages. If it’s for posts, kindly open a new topic.

    Ravi,

    Change this code:
    <?php echo get_the_date(); ?>

    to:

    <?php echo 'Last Updated ' . get_the_date(); ?>

    #2535174
    Ravi Saive

    @Fernando,

    Thanks, i modified the code to align it right side:

    <p style="text-align:right;"><?php echo '<strong>Last Updated:</strong> ' . get_the_date(); ?></p>

    #2535175
    Fernando
    Customer Support

    You’re welcome, Ravi!

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