Advanced query - List products using a word or phrase found in the title or content - Oxygen Builder

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we're going to have a look at the query but this time we're going to use the search query so we're going to get away from taxonomies categories tags attributes and we're now going to look at an option where you can insert whatever you want to pull up the search results so here i have my query and i have two results there i have a hoodie and a t-shirt which are completely unrelated and if i go into my query you'll see that i have the search term which is this s so you simply look for the s in the list of options select the s and then enter the variable or the word that you want now it will select and search in the title and the content so the reason why these items were displayed on the page is because on the actual product page you'll see that the word variable appears this is a variable product and that's why the variable these two products were chosen similarly if i go in and i go with the word like logo which i know appears in some of the titles now all the products that can be used with logo will appear in the results so there we have the items with the word logo in the title in another way let's have a look at a simple product because i know that some of the items are simple products so simple product close save and now when i go and have a look you'll see that simple products are displayed so this is a very easy way to display products by search term in the actual query in the back end i'll just show you how we have it set up so basically we have a standard post type which is a product then we have the post per page which come from a custom field in this case though we could just replace that with the number four then we have the taxonomy query now in this case the taxonomy query isn't required because we're not using the taxonomy query we're just going with the search result then we have the no found rows set to true so there's no pagination order by and in this case let's go with title and the order let's go with ascending and then we have the meta query to check that the items are in stock and that one will keep and then here we have our search parameter so with that change made will update head over to the website and you'll see that in my search results slightly different now but there are the search roles results based on the word logo and you'll be wondering why or what was the search term the search term was simple and if i type in the word logo now you'll see all the items with the word logo appear in the listing what i can also do now is i can also then decide if i want to maybe i want to arrange the sort order there by price and to do that i would head into my query and then instead of order by title i would go meta value number and then if there's a meta value number we need a meta key so we add the parameter and we look for meta underscore key and in the meta key we're going to add the value underscore price and now the items will be arranged by price so in ascending order and if we look in our query then you'll see that the order here is ascending and similarly if i was to change that to descending then the [Music] the price would start from the most expensive if i wanted to restrict my results to a specific category so let's say we want to do it to t-shirt so what we would do then is head over into our query and now we'll do a taxonomy query so we'll add a parameter [Music] tax taxonomy query when we do a taxonomy query there will be two values the first one is the relation so the relation is and and then we have the array with the values so we'll add the values and what we're going to do at this time is we're going to say that the taxonomy and the taxonomy is product cat then we're going to have a look at the field and the field will be the slug then we're going to add the value the terms so the terms in this case we know we just want to do it with t-shirt i'm not sure if it's plural or singular and and finally we're going to have a look at the operator and the operator just says in so let's just have a look and see on t-shirts the correct way for the taxonomy so here we see we're in the product uh t-shirts so if we have a look we'll see t-shirts or you can go into categories in the back end under products and actually go and have a look at the slug so t-shirts it is in plural then we'll head over to the front end there so i'm going to add the s so that's how you can check the category slug we save that and now when i refresh you're going to see that we only have the logo from t-shirts so now only the t-shirts are included in the query i'm going to come to the back and now i'm going to add another value and the other value will be accessories so this is a great way to filter products that are similar from several categories or to only have specific products from the same category displayed in the search results so i hope you enjoyed that video and thank you for watching
Info
Channel: Bruce Young
Views: 177
Rating: undefined out of 5
Keywords: oxygen builder, advanced query, search wp query
Id: i0crsZ_nrSU
Channel Id: undefined
Length: 6min 57sec (417 seconds)
Published: Wed Dec 08 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.