Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Post Archive Sorting by Modified not Published Date

  • The posts in my archive seem to be sorted by last modified versus the publish date. Is this a setting somewhere?

  • Hi Justinfm,

    It should be ordered by Published date by default.

    Do you have any custom snippets? Can you check if one is causing this?

    If there isn’t try adding this snippet:

    add_action( 'pre_get_posts', function($query){
    if ( !is_admin() && ( $query->is_home() || $query->is_archive() ) && $query->is_main_query() ) {
            $query->set( 'orderby', 'date' );
            $query->set( 'order', 'DESC');
       }
    });

    Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

  • I tried this, but it didn’t work.

    I should note, it seems like it’s only happening when you click on a category. The search function brings up the posts in correct date order. I’m not using tags, so I don’t know if it does it in tags.

  • I updated the code I provided to include archive pages. Can you test that?

  • That code worked.

    Thanks,

    Justin

  • You’re welcome, Justin!

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