-
justinfm
The posts in my archive seem to be sorted by last modified versus the publish date. Is this a setting somewhere?
-
Fernando
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
-
justinfm
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.
-
Fernando
I updated the code I provided to include archive pages. Can you test that?
-
justinfm
That code worked.
Thanks,
Justin
-
Fernando
You’re welcome, Justin!
Viewing 6 posts - 1 through 6 (of 6 total)
- You must be logged in to reply to this topic.