- This topic has 7 replies, 3 voices, and was last updated 2 years, 10 months ago by Ying.
-
AuthorPosts
-
June 11, 2021 at 3:36 am #1818395Nikos
hi,
i would like to ask if it is possible to get the latest posts based on the update date and not the created date.
for example, if i created a post on the 1st of june, i would like it to show always the 1st june as the creation date but if i made a change on 7 june inside it, i would like it to go over a post created on 5 june. important, it would be perfect if i had the ability to tell each post that the change i made at it, it is worth to be marked as an update. because if i would just go inside that post to correct a typography mistake, i wouldn’t like the post to go over the other posts just because of that. so there would be perfect if there would be an option for that.
thank you very muchJune 11, 2021 at 5:22 am #1818493DavidStaffCustomer SupportHi there,
you can add the PHP Snippet provided here:
https://docs.generatepress.com/article/generate_post_date_show_updated_only/
This will display ONLY one date … if the post hasn’t been updated it will show the published date, if the post has been updated it will show the Updated date.
Regarding the editor the Theme has no responsibility over the date creation its a WordPress function. Not sure but i found this plugin that allows you to freeze the date:
June 11, 2021 at 6:25 am #1818549Nikoshi david,
1. to understand better, if the post has been updated, it will show the updated day AND being taxonomized by the updated date?
2. very useful plugin
thank you!June 11, 2021 at 7:43 am #1818639DavidStaffCustomer Support1. By default the theme outputs a date line that includes both the Published and Updated (modified) date, one of which is hidden using CSS. That filter will change the date so ONLY one of them is ever output. So yes, with that code if the post has been Updated it will only display the Updated date.
June 11, 2021 at 10:51 am #1819034Nikosi added the php snippet, i made a change in an older post but it does not show it first.
what did i miss or did wrong? π
thanksJune 11, 2021 at 11:32 am #1819069YingStaffCustomer SupportHi Nikos,
The filter only changes which date to show, but it won’t affect the way that WP orders the posts.
If you want the posts ordered by updated date, try this PHP snippet:
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' ); } } );
Let me know π
June 11, 2021 at 11:34 am #1819072Nikosyes that was it !!! thank you Ying !!!
June 11, 2021 at 11:41 am #1819087YingStaffCustomer SupportNo problem π
-
AuthorPosts
- You must be logged in to reply to this topic.