Custom product queries using Oxygen Builder's custom query options the easier way

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
video we can have a look at an easy way to put together custom queries using the custom query builder inside oxygen so here i have an easy post and in the easy post under the query i've had headed over to advanced and now i'm going to edit query and you'll see that i've selected the post type of product and then under the taxonomy query the relationship of and and then we've built the array with the the taxonomy which is product cat for product category we've gone for the field slug the terms then would be the slug so in this case decor and the operator in so that's the query that i've used for this particular post and then of course it outputs the decor item now if i wanted to say include hoodies with this i would then edit my query i'd add another value here and i would say also include hoodies close the parameters and then apply that query and then you would see that hoodies are now also included in the easy posts and there are the hoodies right now to create this query it looks quite complicated but there is an easier way of breaking it down and then looking into it so what i'm going to do is if you head over to a website called croco block and on the croco block website they have a wp query generator and what's really nice about this is that for example here we're doing a taxonomy query it's asking us the same questions i'm simply filling in the answer so when i select relation i say and which is what i had then i've got to enter the taxonomy so you do need to understand what a taxonomy is in order to know if it's a product category or a product tag maybe you want to look at some custom taxonomies then it's the field and the field can only then be one of these four and we've gone for slug here we enter the taxonomy terms so we didn't go for beanie but this is where you'd enter the terms like we we had decor and we also had hoodies and you'll see now that the terms are then completed automatically here and then the operator you have a choice of n not in and exists or not exists now the nice thing now is that here we have the breakdown of the taxonomy query that we're doing inside the advanced query from oxygen builder so if i now go back and compare that so we started with the post type of product we don't we have a post type here of post so what we would do then is go to post and we would enter the post type not sure where it is in this builder but let's just get back here so we know that the post type is going to be product so we've entered product and then we have a look at the taxonomy query which is where the complicated bit really starts so we have the relation which is and and then we have the array now if i look here under add value i've only got the choice of an array or a relation so already when you're doing the taxonomy query you're getting a clue as to what information is required so if i was to rebuild this now knowing what i know so the first thing i would do then is head over to the query generator and i see that the relation that we've built here is the relation and so what i'll do in this case is i'm going to head over here then add a value and i'm going to go with the relation of and so it must be post type of product and it must also conform to the following and that'll be the array now in order to know what to input we already have clues here in the drop down so we can see already here that we need to enter taxonomy i head over here to the query and i see okay taxonomy in this case it's product cat because we want the product categories the next one that we're going to do now is we need to enter the field so what field are we going to use for the terms so the field that we're going to use then in this case will be slug and as we saw here we could of course have used the name the term id or the term taxonomy id so in our case though the slug will work really well the next thing that we need to look at then would be the the terms the taxonomy terms so we'll head back out to the oxygen builder we'll add a field and we're going to look here for terms and you'll see here that because it's an array similar to this array that we created yeah each time you add a term you would add a new block so in our case it's decor and we wanted hoodies and now we need to add in the last value and the last value here is going to be the operator and the operator says it's in it's not in so is the term hoodies or decor in the terms assigned to that product if it is then list the products and then here we're going to go to the operator and we're going to put in n so now we know that we're going to get all the products that are in the categories decor and hoodie so close that and then i would simply apply the parameter to test if that's working properly what i can also do is head over and then just quite easily say not in and how should that be written simply look at the the drop down and you'll see here that this is what it should look like you can even copy that from there and then head over here paste in the not in close the query and then apply the parameters and now everything that's not in hoodies or decor is going to be lifted is going to be listed the other i mean it's really now up to you to to build out the query that you want you can also use the custom query inside [Music] the query facility for easy post but if you want to do something more advanced this is the place to come to now we're going to add another one which is going to be posts per page because maybe we don't want all the posts to show so let's go with posts per page and in this case i'm just going to choose the value of 2 and the reason for that is just to highlight how that works so if i close there you'll see we have several terms i'm now going to apply the query parameter and you'll see now that only two terms are displayed so that would be how we would go about then creating the query that we want and then not only creating but also how many posts we'd like in the output so here maybe i'm going to go for three or let's make it four i can close the window here i can apply the query parameter and there i have the four posts that i requested so that's one quick and easy way to learn how to build those queries and if you're not sure what the terms mean or what information is needed this is a great place to come to get the outline and you can literally then reproduce this layout with the different items inside the advanced query so this just looks at how to build the product query and we'll look at some more advanced queries in future tutorials so hope you enjoyed that video and thank you for watching
Info
Channel: Bruce Young
Views: 585
Rating: undefined out of 5
Keywords: oxygen builder, custom query
Id: 6T9Uq1L59S0
Channel Id: undefined
Length: 8min 16sec (496 seconds)
Published: Thu Dec 02 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.