Site logo

Archived topic

Change position of 'Last updated date' text

4 replies · Started by Dami on July 29, 2022

Viewing posts 1–5 of 5

Hi,

I want to move the last updated text below the post title.

I'm using a Header element to display the post title, and a Hook element and this code to display the updated text: <span class="updated-date-label">Last Updated: </span><span class="modified-date"><?php echo get_the_modified_date('F j, Y'); ?></span>

Hi there,

if you're using the Header Element, then you can:

1. Add the PHP Snippet provided here to your site:

https://docs.generatepress.com/article/show-the-updated-post-date/#show-the-“updated”-post-date-in-header-element

See here on how to add that: https://docs.generatepress.com/article/adding-php/

2. Edit your header element, and below the post title you can add your date like so:

<span class="updated-date-label">Last Updated: </span>{{post_date}}

The code in #1 will make it so the {{post_date}} template tag returns the updated date.

The alternative is to use a Block Element to create your hero, as that has more options that can be set in the editor.

Added the PHP snippet using a plugin and code in #2. But it's showing the published date instead

Also tried using

`<span class="updated-date-label">Last Updated: </span>{{modified_date}}
<span class="updated-date-label">Last Updated: </span>{{post_modified_date}}'

on the front end it shows

Last Updated: {{modified_date}} Last Updated: {{post_modified_date}}

Used [modified_date] instead and that worked.

Glad to hear that!

This archived topic is closed to new replies.