-
Cyrielle
Hello,
I am struggling with sorting some custom posts (team members) I created with ACF and display with a query loop.
I have to put 5 team members first in the list, and then have the others sorted by alphabetical order.
To do that, I added numbers to their slug (0 to 4), and ordered the posts by slug, in ascending order.
When I’m editing my page, it works well, the order is fine, but when I save and check the live page, the order is not as expected at all. I don’t even understand how they are sorted in the front.You can check the website and access it with the private info I joined.
Thanks in advance for your help!
-
Hi there,
that is peculiar, any plugins or code snippets that alter the WP Query ?
-
Cyrielle
Hi David,
I checked and I really don’t think so…
It’s this page if you want to visualize the problem: https://www.keyaidconsulting.com/who-we-are/
I tried sorting them by title, it works fine. Seems like the slug really is the problem here… -
Yeah it looks like a front end bug.
Can you try adding this PHP Snippet to the site:add_filter( 'generateblocks_query_loop_args', function( $query_args ) { if ( isset( $query_args['orderby'] ) && 'slug' === $query_args['orderby'] ) { $query_args['orderby'] = 'name'; } return $query_args; } );
-
Cyrielle
It works perfectly, thank you so much!
-
Glad to hear that!
- You must be logged in to reply to this topic.