Site logo

Archived topic

Add 'publish date' to specific pages

14 replies · Started by Kia on February 13, 2022

Viewing posts 1–15 of 15

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.

Hi there,

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

Hi David,

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

Thanks.

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:

Works a treat! Thank you so much! 👊

Glad to hear that!

@David,

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

Hi Ravi,

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

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.

@Fernando,

Here is the page link

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

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(); ?>

@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>

You're welcome, Ravi!

This archived topic is closed to new replies.