- This topic has 11 replies, 2 voices, and was last updated 5 years, 4 months ago by Tom.
-
AuthorPosts
-
November 14, 2018 at 12:17 pm #727442kunal
Hi Guys, quick question. I’m checking the forum, and I see this question has been asked, however, all of the people asking seem to be very technical experienced.
Question: I’ve activated the Tasty template (premium). And I would like to (a) show the Last Modified stamp on each post and page (2) have my website homepage ordered based on modified date, not just when the post/page was originally published.
Please help!!! thanks!!
Kunal
November 14, 2018 at 12:18 pm #727443kunalAlso, when I’m in my php editor, in the funtions.php file, it says: “GeneratePress. Please do not make any edits to this file. All edits should be done in a child theme.’
Where the heck is the child theme!!??
Thanks
November 14, 2018 at 1:07 pm #727476kunalActually guys, this is EXACTLY the same question I have. I just want to show the updated date, and if it hasn’t been updated, then use the original published date.
https://generatepress.com/forums/topic/post-updated-date/#post-470725
(1) I see the code Tom has provided in that thread. But I have no idea where I would be copy/pasting this code in. I’m checking the page.php file, I can’t see where I would paste this in!
(2) and naturally, I want the ordering on my homepage to be updated such that posts are ordered by the modified date (or if not modified, by the originally published date)
Thank you so much!!
Kunal
November 14, 2018 at 6:19 pm #727642TomLead DeveloperLead DeveloperHi there,
This is the code for the updated date: https://docs.generatepress.com/article/show-the-updated-post-date/
It can be added using one of these methods: https://docs.generatepress.com/article/adding-css/
As for the second question, you can try this:
add_action( 'pre_get_posts', function( $query ) { if ( $query->is_main_query() && ( $query->is_home() || $query->is_search() || $query->is_archive() ) ) { $query->set( 'orderby', 'modified' ); $query->set( 'order', 'desc' ); } } );
Which can be added using one of these methods: https://docs.generatepress.com/article/adding-php/
As for a child theme, this should help: https://docs.generatepress.com/article/using-child-theme/
November 15, 2018 at 10:48 am #728281kunalHi Tom, thanks, would I copy/paste your code:
add_action( 'pre_get_posts', function( $query ) { if ( $query->is_main_query() && ( $query->is_home() || $query->is_search() || $query->is_archive() ) ) { $query->set( 'orderby', 'modified' ); $query->set( 'order', 'desc' ); } } );
in the function.php file? Because when I go to the functions.php file, it says:
/**
* GeneratePress.
*
* Please do not make any edits to this file. All edits should be done in a child theme.
*
* @package GeneratePress
*/I’m just curious where I would paste the code you provided?
November 15, 2018 at 1:02 pm #728401TomLead DeveloperLead DeveloperYou would add it using one of these methods: https://docs.generatepress.com/article/adding-php/
November 15, 2018 at 1:22 pm #728415kunalTom, TRES AWESOME.
Works!
Thankyou so much!!
K
November 15, 2018 at 3:20 pm #728483TomLead DeveloperLead DeveloperYou’re welcome ๐
December 5, 2018 at 2:30 pm #749144kunalHi Tom, another quick question. Where do I put the [modified date] tag?
I updated a post, but I want it to show up in under the title of the post. For example, I just tested on one of my pages: http://albertacostandquantitysurveyorguide.com/what-is-a-construction-preliminary-list/
And it says “admin . November 13, 2018”
I would like it to say “admin . last updated December 05, 2018” (for example, since I just updated it today)Thanks!
KunalDecember 5, 2018 at 6:15 pm #749270TomLead DeveloperLead DeveloperGive this CSS a shot:
.page-hero time.updated { display: inline-block; } .page-hero time.updated:before { content: "Last updated on "; } .page-hero time.updated + .published { display: none; }
December 6, 2018 at 10:14 am #749931kunalThanks Tom! Works well!!
Kunal
December 6, 2018 at 5:22 pm #750179TomLead DeveloperLead DeveloperYou’re welcome ๐
-
AuthorPosts
- You must be logged in to reply to this topic.