#102 – date modified

Posted in ‘weeblrAMP’
This is a public ticket. Everybody will be able to see its contents. Only enter usernames, passwords or any other sensitive information in the Private information field.
Wednesday, 25 July 2018 10:15 UTC
 Hi guys, I's like to display date modified INSTEAD of date published. Is there a simple way to accomplish this?

Wednesday, 25 July 2018 11:44 UTC
Hi Freddie,

There are 2 common ways you can do this:

- using a template override
- using a filter

Template overrides are described on this page of the documentation. With this method, you would need to override the weeblramp/frontend/amp/contents/item_author layout and change:

$date = $this->get( 'date_published' );

$date = $this->get( 'date_modified' );

in your template override around line 73.
Also best to maybe to change:
<time itemprop="datePublished"

<time itemprop="dateModified"
as well on line 92

The filter method might be just a bit simpler actually:

- create a child theme if not already done.
- in that child them, create a weeblramp folder
- in that weeblramp folder, create a functions.php file
(more details on this page of the documentation)

Then in that AMP-only functions.php file, add the following:

 * Sample frontend functions.php for weeblrAMP

// Security check to ensure this file is being included by a parent file.
defined('WEEBLRAMP_EXEC') || die;
	function ($data) {

		if (!empty($data['date_modified']) && !empty($data['date_published']))
			$data['date_published'] = $data['date_modified'];
		return $data;

In that filter we simply replace the date_published field with the date_modified one.

Best regards
Wednesday, 25 July 2018 12:33 UTC
Thanks guys, your explanation was perfect.

Wednesday, 25 July 2018 13:37 UTC

You're welcome! Can I ask which method you used and maybe what's your site (put the link in the Private information area if needed). Always interested to have info about nice AMP implementations :)

Best regards

Wednesday, 25 July 2018 13:55 UTC
Hi, I modified the existing item_author.php file (I know a child theme or function would have been much better, but time constraints won out in the end.) I will create a child theme at the weekend :o)

thanks again
Wednesday, 25 July 2018 13:58 UTC

Ah yes, that's fine for validating the thing but be sure to push that into a child theme or it'll be wiped out at next update. Yes, over the weekend is fine, no update until then!

Interesting, that's an AMP-only site! not the most common use but it does make sense.

Best regards

Thursday, 09 August 2018 05:34 UTC
This ticket has been automatically closed. All tickets which have been inactive for a long time are automatically closed. If you believe that this ticket was closed in error, please contact us.
This ticket is closed, therefore read-only. You can no longer reply to it. If you need to provide more information, please open a new ticket and mention this ticket's number.