[Resolved] Last Modified Date and List my Posts based on Modified Date

Home Forums Support [Resolved] Last Modified Date and List my Posts based on Modified Date

Home Forums Support Last Modified Date and List my Posts based on Modified Date

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #727442
    kunal

    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

    #727443
    kunal

    Also, 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

    #727476
    kunal

    Actually 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

    #727642
    Tom
    Lead Developer
    Lead Developer

    Hi 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/

    #728281
    kunal

    Hi 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?

    #728401
    Tom
    Lead Developer
    Lead Developer

    You would add it using one of these methods: https://docs.generatepress.com/article/adding-php/

    #728415
    kunal

    Tom, TRES AWESOME.

    Works!

    Thankyou so much!!

    K

    #728483
    Tom
    Lead Developer
    Lead Developer

    You’re welcome ๐Ÿ™‚

    #749144
    kunal

    Hi 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!
    Kunal

    #749270
    Tom
    Lead Developer
    Lead Developer

    Give 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;
    }
    #749931
    kunal

    Thanks Tom! Works well!!

    Kunal

    #750179
    Tom
    Lead Developer
    Lead Developer

    You’re welcome ๐Ÿ™‚

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.