• Gyurmey

    (@gyurmey)


    Hi,

    How do I add my own sort to a Query Loop Block?

    Earlier (without Gutenberg) in the PHP file I added:

    $wuery->set('orderby', 'menu_order');
    $query->set('order', 'ASC');

    But it doesn’t work anymore.

    • This topic was modified 2 years ago by Gyurmey.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Kathryn Presner

    (@zoonini)

    Hi @gyurmey – there’s a typo here: $wuery so perhaps that’s the issue?

    If that’s not the problem, could you share more about your end goal so I can better assist?

    Also, please let me know what theme you’re using. Thanks!

    Thread Starter Gyurmey

    (@gyurmey)

    Hi @zoonini, yeah that’s a typo.

    I use Custom Post Order plugin and I would like to sort my custom posts according to the order menu.

    I used to use pre_get_posts action, but now it doesn’t work.

    WP: 6.1
    Theme: TT3

    @gyurmey to be clear, do you want to add a UI element to be able to choose the sortBy or to have them be sorted via code?

    Either way, it’s probably best to register a block variation for this as you most likely don’t want to affect all instances of the Query Loop block.

    You can start by looking at the example in the documentation – here.

    Thread Starter Gyurmey

    (@gyurmey)

    @welcher, thanks for your response.

    I would like my client to be able to choose this option himself from the list. Now that’s not possible.

    Moderator Kathryn Presner

    (@zoonini)

    Hi @gyurmey – I asked another developer, @greenshady, to take a look at this. Justin suggests that you have a look at his query-loop tutorial to help point you in the right direction, along with some of the query-loop YouTube videos that @welcher has done.

    He suggests that you go through the process of learning how to build a Query Loop variation on your own, and once you learn that on your end, it’d be easier to make smaller code adjustments if you still need help at that point, which would be more in line with the scope of this support forum. Cheers!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Query Loop Block + sort by menu_order’ is closed to new replies.