[Resolved] Query Loop: Order by Slug – Problem on Frontend

Home Forums Support [Resolved] Query Loop: Order by Slug – Problem on Frontend

Home Forums Support Query Loop: Order by Slug – Problem on Frontend

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2355047
    Paul

    Hi!
    I’m facing an issue with the Query Loop. I want to display several posts in alphabetical order of the slugs. This works fine on backend but on the frontend the order corresponds to the sorting by date. If I change the setting to something different (e.g. sort by last modified date), then backend and frontend will be identical.

    For testing purposes I deactivated all functions and also all other plugins. But this didn’t help.
    I also have the newest version of GP installed.

    The problem remains only with the slug. I hope, you can help me.

    Best
    Paul

    #2355826
    Fernando
    Customer Support

    Hi Paul,

    To clarify, do you have an Order by parameter in your Query Loop Block? Can you try removing that?

    If that doesn’t work, can you start a topic here instead?: https://community.generateblocks.com/

    #2356111
    Paul

    Hi Fernando!
    Yes, i have an “Order by” parameter in the Query Loop Block. I essentially need it to display the posts the way I want (via “Order by Slug” and “Ascending”). I tried deleting the Parameters and readding them, but that didn’t work.

    Sceenshot of Query Loop settings in the backend

    #2356837
    Ying
    Staff
    Customer Support

    Hi Paul,

    It seems like a front-end bug to me, we will try to fix it in the next release.

    For now, can you try this filter?

    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;
    } );

    You can add it to a plugin called code snippet, or if you are using a child theme, add it to the child theme’s functions.php.

    Let me know!

    #2356875
    Paul

    Dear Ying,
    thank you so much, this worked perfectly!
    Your support is so awesome!
    Best
    Paul

    #2356945
    Ying
    Staff
    Customer Support

    You are welcome 🙂

    Thanks for letting us know about this issue!

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