Hi.
I´m using the SiteOrigin Post Carousel Widget and want to make a query using logic conditionals. Is it possible? How?
Example:
I have post”A” with categories 1, 2 and 3; post”B” with categories 1 and 3; post”C” with category 2; post”D” with categories 2 and 3; and post”E” with category 3.
I want to query taxonomy category:1 AND category:3. The result should be only post”A” and post”B”, since those are the only post that satisfy both parameters.
I hope I made myself clear, since english is not my native language.
I’d appreciate any help. Thanks.
Logical query in Post Carousel Widget
This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.
Hi :)
Thanks for reaching out.
When editing the Post Carousel widget you can open the Posts query section, there you’ll see the available options for building a query. You can use the Taxonomies field in the query builder to search for the categories you’d like to add.
Hi. Thanks for your answer Andrew.
I’ve been using the widget the way you recommend. But unfortunately that way of searching does not take logic conditionals. Or more probably, I don’t find how to do it.
Consider this other example, please.
A videos site. Netflix style. With movies, series and documentaries. Every post is a new video. Under Categories, we have Movie, Serie, Doc, Action, Comedy, Suspense, Nature, Science, New release.
When I make a post for a new video, under Categories, I check if it’s a movie, a series or a documental. And also, its genre, and if it’s a new release.
Then I want to query new action movies.
Using the taxonomies for the search, when I add the categories to search, like Movies, Action and New release, I get as result, every movie (all genres), every action movie or series, and every new relase under movie, serie or docs.
I want to search like (Movie && Action && New release) and get only the result that satisfy those three parameters only. Excluding Action Series, or Comedy Movies, or New Documentaries.
Hope you can help me Andrew. Or anyone who knows how to, please.
Thanks for your feedback. Ideally, we’d add to the Additional field
'category__and' => array(15,19)
, assuming 15 and 19 were the category ID’s being targetted. The Additional field doesn’t support PHP which means we can’t make use of this option.To change the behavior of the Post Loop widget taxonomies field from OR to AND, you can use the following:
This function can be added to a child theme functions.php file or by adding a snippet to the plugin Code Snippets. If you make use of Code Snippets, set the snippet to run on the site front-end.
We aren’t usually able to assist at this level within our free support scope but I’ll be adding the above to our documentation soon so it’s no problem sharing it here first. Hope this helps :)
Thank you Andrew.
Tonight, I will try this method. Seems possible to work.
I’ll let you know later the result.
Thanks again.
For sure :)
It worked like a charm! Thank you again Andrew. That was the solution.
Although it’s a pity that we can’t use logic conditionals for search in the taxonomy field of the post query builder.
I hope it will be able in future versions.
Have a great day.
Glad to hear you’re making progress. I’ll be sure to pass your feedback onto the team. All the best :)