Open maltmann-muc opened 1 year ago
++ 1
+1
+1
Examples of this feature or functionality. Bricks is an example. It merges the main query for archive and search pages with custom query settings by default. If you do not want this behavior for specific queries you can disable it using a filter: https://academy.bricksbuilder.io/article/filter-bricks-posts-merge_query/.
+1
+1
+1
+1
+1
+++++++++++++++++++++++++++++++=1
+1
+1
+10
Examples of this feature or functionality. Bricks is an example. It merges the main query for archive and search pages with custom query settings by default. If you do not want this behavior for specific queries you can disable it using a filter.
Thank you, @andreslotta, for this precious additional input. I never used Bricks enough to be aware of this feature.
Your description reads "you can disable it using a filter". That's kinda similar (roughly, and in the opposite way) to using a pre_get_posts action in Oxygen. Having a simple toggle could still beat Bricks ;-)
+
YES, would very much like this feature!
+1 Would be a great addition to Oxygen
+1
@maltmann-muc Can you explain a scenario where you'd want to modify a default query's tax_query?
@maltmann-muc Can you explain a scenario where you'd want to modify a default query's tax_query?
@Spellhammer, you're investigating/working on it? ❤️
tax_query sample: (from my head) Default category archive query uses a tax_query to dynamically select the current category, e.g. 'projects'. I often had the requirement to add a negative filter, like show all of 'projects', but not those with secondary category 'hidden'. The default tax_query is probably something like (simplified)
[
[
'taxonomy' => 'category',
'field' => 'term_id',
'operator' => 'IN',
'terms' => get_queried_object_id(),
]
]
I wanna add my filter to produce something like this:
[
'relation' => 'AND',
[
'taxonomy' => 'category',
'field' => 'term_id',
'operator' => 'IN',
'terms' => get_queried_object_id(),
],
[
'taxonomy' => 'category',
'field' => 'slug',
'operator' => 'NOT IN',
'term_ids' => 'hidden',
]
]
Thanks @maltmann-muc!
WordPress does a great job in creating dynamic queries from the URL like for post archive (blog), taxonomy archive, search, etc. Oxygen Advanced Query does a great job for creating custom queries by offering a sophisticated UI.
Unfortunately, you can't combine those two: Either have the default dynamic WP query, OR have a fancy UI to create a new static custom query. Currently, the only way to modify the default query is by implementing a "pre_get_posts" hook function.
Feature I'd like to suggest Option for Advanced Query to modify the current query instead of creating a new query.
I'm aware it will be a challenge to implement appropriate logic to the modifications, e.g.
What are the use cases for this feature? This new feature would allow to modify default criteria without losing the power of WP's default dynamic query. And without the need to manually implement a "pre_get_posts" hook function.
Typical query parameters that would often need to be modified for default queries are:
Some real world use cases which currently require a pre_get_posts hook function are described in Yan Kiara's Gist: https://gist.github.com/yankiara/c43da83662a14e7609b4e23f6d82717a
Examples of this feature or functionality. If another product has done it well, provide examples here. Not aware of any. You could be the first to offer this genius feature ;-)