#108 Query Block Bugs and Server Updates

## Metadata
- Author: [[WP Café]]
- Full Title: #108 Query Block Bugs and Server Updates
- Category: #podcasts
- URL: https://share.snipd.com/episode/d6d7ce6c-6b9e-4f90-8fb1-aa6d9ff7e45d
## Document Notes
## Highlights
- **Navigation Block Challenges**
- Building a complex, interactive four-level menu in WordPress proved challenging due to the navigation block's limitations.
- Keith Devon opted to use the Classic Menu Block plugin for better control over the menu's structure and behavior.
Transcript:
Keith Devon
Yeah i mean as always it's kind of difficult to describe this stuff uh with words i'd love to be able to show i know we're on youtube but people also listen to this as a podcast so i'll do i'll Do my best but the menu it's quite an extensive menu so it's four levels deep so this is the main menu of the website it's it's going to be this isn't my choice it's going to be hidden by default Behind like a little burger icon on all screen sizes. And then it slides in as a like panel whenever you click the icon. And then, yeah, like I said, there's kind of four levels to it, which is quite a lot for a main menu, I would say. And the way it's very interactive in terms of like you initially just see the first level and then you can either click those links or you can click the expand icon then a second panel kind Of comes in and shows the rest of it and the the third and fourth levels are hidden within little kind of accordions uh so lots and lots going on um so yeah i didn't really know how to approach It to start with but i thought i just need some markup to work with and then i'm just gonna like start building this with like my javascript and css um so i i think i initially used the page List block and that was a stupid i don't know why i did but i knew it was it would give me like a a structured menu basically uh like sub lists and things like that and i think i didn't use the Navigation block yeah i didn't use the navigation block because it already had too much behavior built in like show and hide and like the sub menus and stuff i was i don't want to have to Be like overriding all that stuff so i tried that first and thought this is going to be too complex because it already does too much um badly uh and uh so i decided i'll use the page list block And then i'll give me the markup i need and i'll just work from that so that's what i did and then i realized you know obviously eventually i can't actually use the page list block um because I can't tell it what should be in it if that makes sense so we were like well we can use class classic menus we know there's a way to enable classic menus um so that's what we did so i i swapped Out all the javascript and css that i'd for originally for the page list block updated it to work with with the uh classic menu block which we have used uh it's a plugin from jonathan harris Um spaced monkey if you know i'm kind of on socials uh so we use that to give us the give us a block and that's what we've done. And it's working quite well. There was lots of technical little intricacies. Maybe we'll get into the details of that one day. I'd love to do like a full kind of debrief of this project at some point, probably not as like one episode, but like lots of little bits of content, like how we built this bit, how we built, Cause there's been loads of little interesting technical challenges. Um, yeah, Mark's just it up on the screen there. So the classic menu block is at wordpress.org forward slash plugins forward slash classic dash menu dash block. Go check it out. But we don't think that enables the menu item to actually build the menus, do we?
Mark Wilkinson
Yeah, so to re-enable classic menus it's just add theme support uh type thing you need to do um but it doesn't appear that plugin does it which is a bit strange i would have thought it is Weird as doing this block section so it just gives you a block and then it just lets you choose a classic menu that you've made in the classic menu section basically which is quite nice Yeah which is good so yeah ([Time 0:03:47](https://share.snipd.com/snip/133ddc3d-0962-488c-9dfe-2886a6595984))
- **Placement of Interactive Blocks**
- Consider the placement of interactive blocks, like navigation menus, within the WordPress editor.
- Hiding them completely hinders editing, while displaying them can clutter the interface.
Transcript:
Mark Wilkinson
More challenges go on what what so major i know it took i think the concepts of the menu and the panels just took a long time to build so i think that's you know that's a different story almost But um you know what were what were the sort of challenges in terms of the block editor uh and the full set editing sorry in in this this particular thing where where do we put that block
Keith Devon
It is is the is for me the main one so we've got this classic menu block and yeah i mean i started off just doing everything in the footer because i just wanted things kind of out of the way And everything's going to be hidden by default. So that's fine. But then we thought, well, it probably should be at the top of the page because it is the main navigation for the site. You could argue that maybe it shouldn't be actually. But anyway, that's the question is where does this go in the block editor? Do I put it in the header pattern template part or the footer template part? Do we load it in a different way? It just doesn't seem to be a sensible place to put it because it doesn't look good in the editor because you've got to open it. It's got all that interactivity, which doesn't work at all in the editor.
Mark Wilkinson
Yeah, and do you want it to work in the editor? I just don't think you do. But then you also don't want it to get in the way of the header content. Like when you edit in header, you don't want all this stuff there that just doesn't look right, do you? ([Time 0:07:27](https://share.snipd.com/snip/90b7cb92-055c-4d87-a693-4b886a67f942))
- **Using AI for Coding**
- Use AI tools like ChatGPT for coding assistance, but be prepared to debug.
- Fixing AI-generated code can be difficult if you don't fully understand its logic.
Transcript:
Keith Devon
Talked a lot about this already, but I used chat GPT a lot to help me with the JavaScript. And it was an interesting one because obviously it does an amazing job, but I spent a lot of time trying to fix things that had got wrong that subsequently then I didn't understand because I hadn't written the code. So it would have been a really interesting i you can't kind of possibly do this really but like i'd love to like split myself in two like one of one of me uses chat gbt and one of me does it from Scratch and see who actually gets to the end of this because the chat gbt me would make loads of progress really quickly and then get stuck and i wonder if the one that's just built it from Scratch would actually get there, like just step by step by step, like tortoise and the hare kind of thing. ([Time 0:11:20](https://share.snipd.com/snip/7f8cd9c3-28a2-4fec-9437-d0ce4fa4f63a))
- **Client Success with Block Editor**
- Clients successfully populated website content using block styles, custom blocks, and patterns, despite lacking prior experience with the block editor.
- This demonstrates the effectiveness of simplifying the editing experience for non-technical users.
Transcript:
Mark Wilkinson
Got a comment, which is interesting. Courtney, thank you for your question, comment, question. Are you surprised at how many technical challenges you faced with the page builder? I assume you mean like full site editing. Would clients be able to build their own websites successfully? So this is an interesting one.
Keith Devon
I just tried the question the first time. Yeah, this is a good question.
Mark Wilkinson
So we were just saying this morning, actually, we've been looking, the site's nearly out to go live. It'll probably go live early next week. So we've just been sort of clicking around checking things over and the client has done such a good job at making all the pages and the content now obviously we've tried to put things in Place to help them do that um but they have like some of the pages look beautiful and and they've they've done all of them you know in terms of adding the content in and making the right buttons And groups and columns and media text rows and so forth. They do look really nice. That's a little bit different to building a whole website, though. They're actually just in the editor building the pages. So I think for me, to answer the question, would your clients be able to build their own websites? No, I don't think they would. I think they would.
Keith Devon
They possibly will be some help but they wouldn't be able to do it from scratch i mean i think they would but it's really not easy yeah like in the same way i could probably build my own house But i don't have any of the skills to do it today and it'd be a lot quicker to get a builder to do it you know i can probably learn things on youtube and whatever but like yeah it's not loads Of it just is not intuitive like i don't know how a non-wordpress non-techie person would would come into the the block out of the current state of wordpress and then build a site from Scratch but maybe a super simple one, but.
Mark Wilkinson
Yeah, I think super simple one. But I think that's probably another discussion. Like it is, you need some knowledge, but then I guess you need some knowledge for everything, don't you? So that's the difference.
Keith Devon
Yeah, but I did want to echo, I did want to echo what you said there, Mark. I was very surprised at how well the site was coming together, considering most of the content has been added by our clients who are not experienced at all using the block editor yeah I think that's a bit of a testament to the to the attention that we give that process you know yeah we try to make things as easy as possible um so yeah that's been a real success content population
Mark Wilkinson
Success down to the fact that you use things like block styles over CSS classes. Some outcome different. Yeah, that is part of the reason. Yeah, definitely for sure. We've done a lot to try and help them make it a success.
Keith Devon
And the default styles that we've talked about in previous episodes. And the custom blocks where we've needed custom blocks.
Mark Wilkinson
And all the patterns that we've set up that needed to be set up. All that kind of stuff. Definitely has helped. Yeah. Which is nice. It's nice to see the work we've done to try and make it easier is actually paying off because the content and the pages look nice. ([Time 0:12:17](https://share.snipd.com/snip/64728d48-4599-467e-bf1b-dee9240b10a3))
- **Query Block Bug with Sticky Posts**
- The query block exhibited unexpected behavior with sticky posts, fetching multiple posts despite being set to retrieve only one.
- This discrepancy between editor and front-end behavior, confirmed as a bug, highlights potential issues with the query block and sticky posts.
Transcript:
Mark Wilkinson
So that's something that's been nice to see. Quickly going to move on because I'm conscious of time. So quickly we'll go to the query block. So we have used the query block extensively on this site for like grabbing the latest three things and putting them in this section obviously on the home page for the latest news for the Archive pages all sorts of things have used the query block and you came up with a bug actually that seems to be a bug actually yeah a couple of reasons um so do you want to explain what that Was because i know it was a bit of a pain.
Keith Devon
Yeah. Yes. So on which page? What exactly was I trying to do? It was the What's On. Oh, yeah. I was just trying to grab the latest post. So I've had a grid of loads of different things, like galleries and blogs and videos and events and blah blah blah and one of the grid items is just the latest post one single latest post So i added a query loop block um i set it all up nicely and i set the post per page to one and everything looked good in the editor and then i looked on the front end and i had four posts what uh And i actually had a i actually had the second block i used this exact same query but with an offset of one i couldn't use the same query loop for technical reasons but i just i wanted the First post in the second post um and it also had four and i said what the hell uh and i we were talking about it and you said and it's something i'd kind of thought about but haven't tested You're like i bet it's something to do with sticky posts yeah i was like yeah i was like i think you're right i think you're right and we tested it was exactly that so what was happening? So in the query loop, there's a setting called sticky posts, and it has three potential options, include, exclude, or only. And the default is include, so I hadn't touched anything. So what was happening on the back end it was actually this is the weird thing on the back end it was doing it right as far as what i wanted the behavior to be it was grabbing the latest post On the front end it was grabbing all the sticky posts and the latest post so there there's a definite bug there in terms of like the editor and the front end not behaving the same way so there's A bug there but there's also that is actually how the query loop or the wp query i think is supposed to work with with sticky posts you're supposed to show the sticky posts and then show Everything after but i just think that's ludicrous work okay i i agree but what's interesting is that i think in the in the wp query you can there is like an ignore option or something like It yeah yeah but that isn't in the ui and so eventually i i was posting about this on on blue, saying this is kind of what's happening. Mark, who's watching along, Mark Hiles-Meade, hello. He was like, yeah, I think that sounds like a bug or whatever. I then looked it up. I did some more testing on like a completely blank install. Exact same behavior. Looked it up. There is an ish GitHub issue. It looked like nothing was happening with it, but there is actually a related pull request. So they are fixing it. And this apparently could be something to do with the... God, we're 10 minutes away, right? It could be something to do with the REST API and what it allows you to do with sticky posts. And that is why the ignore option was left out because it doesn't work with the REST API for whatever reason. So the reason that option is, yeah, it's crazy.
Mark Wilkinson
I think for the block, if you say I want to show one post, you should only ever get one post. So if you're saying include sticky posts, then that will be a sticky post. That's fine, I think. And if you say exclude them, then it shouldn't be no sticky posts and you'll still get one post. But to get four when you've said one is just completely confusing for a user. And I know it uses the WP query behind the scenes, I would imagine, and therefore it's following what that does. I'd argue that's perhaps incorrect as well. But anyway, I think they've got to fix it for a user point of view. If you say, I want to show one post, you get four. That is just...
Keith Devon
And the language of the options is confusing. So the default should almost be sticky posts first so that could be your default and then it could be something like include which is just include the sticky posts in amongst all the other Posts and then exclude don't show the sticky posts and then only only show the sticky posts those are the four options you need. And it's just naming. I think naming them correctly is probably important, like you say.
Mark Wilkinson
Yeah, that's true. Mark said he doesn't trust you. He's just tested this in two installations, and he can confirm that it's definitely a bug. So anyway, there you go. It is a bug. So it looks like they're on it because it has some chatter on GitHub and things maybe that's going to come into either 6.8 or maybe a fixing release. Who knows? 6.8, yeah. I would imagine 6.8. I would imagine that's not something they're going to throw into a point. Is it not a point release? Whatever they call it, like 6.7 or whatever. ([Time 0:15:10](https://share.snipd.com/snip/3c41b8bf-b68a-40e5-b64f-815d33f4a501))
- **Importance of Server Updates**
- Regularly run server updates, even non-critical ones, to avoid potential compatibility issues.
- Mark Wilkinson experienced server instability after running overdue updates, emphasizing the importance of frequent maintenance.
Transcript:
Mark Wilkinson
Yeah. Quick one from me. We've run out of time, but quick one from me. So I was doing some work on the server for this current client. We use SpinUpWP, not a sponsored thing, but we use it. It's really good. And in the back end of SpinUp, I was looking around. I can't remember what I was doing now, but I was trying to find something. And I noticed this server updates, critical updates non-security updates and i was like what are they so i like clicked it and then it said you've not run these since april 2023 i was like Oh my god what have i done um so it turns out that spin up wp probably rightly so don't install they only install what they consider critical security updates automatically on your server. And I know that because I get an email that says you need to reboot your server, which is fine. But they don't install the non-critical ones. Now, you could argue, and I don't know because I'm not an expert, but you just don't need them. You don't need to worry about this at all. You could just leave them um but i had a lot to run so i followed the instructions to run them which meant ssh into the server which means a whole world of pain for me because i just don't get On with it and it doesn't like me but i managed to log in and i managed to run them which then proceeded to break the server because there was probably so many um dependencies weren't there And so forth so it took me a while with the excellent help of SpinUp WP support to fix that, reboot the server and get it up and running again. So just something, if you're using it, I literally didn't know I had to do this. I thought that they were done because I get the email saying there's been an update, reboot your server, but it's not. You do need to run those yourself. So running them regularly and the support suggested once a month i'm probably gonna do it once a week i think just at the end on friday morning just a bit of a maintenance um you know getting You getting you to upgrade those is probably that to run them is probably the best way and as you're only doing a few the less likely to break because obviously you're not going from sort Of like a really old versions to really new versions and things like that. So anyway, just something I thought I'd mention. And then the last thing is we mentioned our stats counter plugin on the last episode or the episode before. Then we, that is now on GitHub. If you go to the high rise digital GitHub, you'd probably be able to see it. And I'm currently just testing it, and I need to put some information on that page. I haven't got around to doing like a readme yet. I'm putting it on there, but that is there. So if you want to do a little stats count, it just counts up a number on the page when that block is in the browser window, isn't it? I think it is. And you can set like a duration on the block to say, I want it to count up for four seconds or two seconds or whatever. So worth keeping an eye out if you're interested in that anyway, that's fine. Tim has made some comments. I always listen to Tim when it comes to security and service. You do need them and not running regular, this is a quick way to break your site. As I found out, Tim, thank you. So do run them regularly. I will be doing them once a week. Tim says, you can set them automatically. I did notice that on the documentation for spin-up, but I kind of assumed that because they weren't doing that, it wasn't the right thing to do. So I've left it as a manual thing for now. Who knows? I might change that at some point in the future. But everything's back to normal, so I'm just going to leave it alone for a while. ([Time 0:21:41](https://share.snipd.com/snip/c951cb8d-5c97-4391-9d2d-e0e7d32f57ce))