Site logo

Archived topic

Query Loop: Order by Slug – Problem on Frontend

5 replies · Started by Paul on September 27, 2022

Viewing posts 1–6 of 6

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

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/

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

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!

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

You are welcome :)

Thanks for letting us know about this issue!

This archived topic is closed to new replies.