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 sorting differs from back to front

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

  • 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;
    } );
    
  • It works perfectly, thank you so much!

  • Glad to hear that!

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