Site logo

Archived topic

Custom "order by" prevents Query Loop form loading in backend

28 replies · Started by Alessandro on August 3, 2022

Viewing posts 16–29 of 29

In your site, where can we specifically find the Query loop block?

There's one on the About page and on the Homepage (same block)

To clarify, by “it” not working, do you mean that the Query isn’t ordering as expected, or are you referring to it still appearing “no results found” in the editor?

Sorry, I meant the "No results found" error. The query itself has always worked fine, it's just not editable in Gutenberg unless I temporarily change the sorting to some other method than "menu order". Not a huge problem.

That’s odd, I tried viewing the edit page from my end, and I couldn’t replicate the issue. The Query loop block is showing results.

Can you try viewing from a different browser or device? Might be a cache/device issue or a WordPress glitch.

I had removed Menu Order just now (for testing). I added it back – you can see the problem persists. It's OK if we can't resolve this, I thought I was missing something obvious but I understand the PHP function is not standard.

I see. As Ying mentioned, “As menu order is for pages usually, even we use the code to add it to the posts editor in admin, but the function that generates the preview of GB query loop doesn’t know.”

Using the function I provided is an alternative if you want the order setting, and still see the posts in the editor.

The provided function still causes the same problem though. It's currently active on the dev site.

You need to remove the order by parameter from the query loop blocks.

And I'm not seeing the class has been added to the query loop block, nor the function that Fernando provided in your child theme.

If I do that the blocks become visible in Gutenberg, but the ordering does not work correctly. Maybe I added that CSS class incorrectly?

Edit:

And I’m not seeing the class has been added to the query loop block, nor the function that Fernando provided in your child theme.

It is there.

If I do that the blocks become visible in Gutenberg, but the ordering does not work correctly

I was checking the home page, it seems you've added the class to the about page.
Is this the correct order?
https://www.screencast.com/t/3CGLgjh4

Oh yes sorry, it was indeed the About page. And no, the order is not working. Stacey should be last in the list.

Oops, I must have reverted back to the previous function... it is working now! Thank you!

This archived topic is closed to new replies.