Join the Soledad Facebook Users Group here
for Share, assistance, discussion, and Updates related to Soledad WordPress Theme.

If you can't create a new ticket - you can send us an email via our contact form and we will get back to you.

Okay
  Public Ticket #2854097
Changing last posts' order to last update
Closed

Comments

  • LazyBit started the conversation

    Hi dev,

    I would like to change last posts' sorting from published to modified on home and category pages. Can be done without using any plugin?

  •  2,492
    PenciDesign replied

    Hi,

    You can change this via Appearance → Customize → General → General Setting, check Display Modified Date Replace with Published Date.

    Regards,
    PenciDesign.


  • LazyBit replied

    Hi,

    As far as I can see that option just change which info is displayed. I would like posts to be sorted by modified date (last update) instead of by publish date.

  •  2,492
    PenciDesign replied

    Hi,

    Please install the Code Snippet plugin then create a new snippet with the following content:

    function lazybit_orderby_modified_posts( $query ) {
        if( $query->is_main_query() && !is_admin() ) {
            $query->set( 'orderby', 'modified' );
            $query->set( 'order', 'desc' );
        }
    }
    add_action( 'pre_get_posts', 'lazybit_orderby_modified_posts' );

    Regards,
    PenciDesign.

  • LazyBit replied

    Works good, thank you!