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.

GB Query Loop: order by pages WP default order

  • Hi,

    I’m using Query Loop to show pages. But I cant set order view (it’s showing most recently first). Any way to order using the default pages order on wordpress?

    Thank you

  • Hi there,

    Any way to order using the default pages order on wordpress?

    Are you referring to the order option in the page quick editor?
    https://wordpress.org/documentation/article/create-pages/#using-the-quick-edit-option
    Let me know!

  • Hi, Ying

    Yes!

  • I see.

    In this case, try the solution below:

    1. Add an additional CSS class to the Grid block of the query loop block, eg.order-by-menu-order.

    2. Add the below PHP code:

    add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
    		if ( ! is_admin() && ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'order-by-menu-order' ) !== false ) {
    			$query_args['orderby'] = 'menu_order'; 			
    		}
     
    		return $query_args;
    	}, 10, 2 );

    You can use one of the methods mentioned in this article to add PHP code:

    Adding PHP

    Let me know how it goes 🙂

  • Hi, Ying

    It actually works. But I would like to reverse the order.
    For example I have set: 1, 2, 3, 4
    But it’s showing: 4, 3, 2, 1

    I think I’m doing everything right

  • Hi there,

    in the Query Loop you can Add Parameter:

    1. Order By -> Menu Order

    2. Order -> DESC or ASC depending which way you want them

  • Works!
    Thank you, David.

  • You’re welcome

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