-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add multiple taxonomy options to the query block #44041
Comments
Hi, are you able to you provide testing instructions that does not involve third party plugins (ACF)?. |
Dear Carolina,
I am not but let me try dig a bit deeper. I am not sure if the filtering problem also happens with tags (my set up uses a custom taxonomy - I have no tags).
However, all I can say is that I could not get rid of the problem with 6.0.2. I had to roll back to 6.0.1 and then everything was fine again. So something has happened between the two versions.
My more basic question was whether the functionality I was using was intended or not. To be specific:
It is extremely useful to be able to filter “the loop” in context (say a custom category page). To do this you have to remove the “inherit query from template” option, set your filters, then reapply “inherit query…”
After the issue I noticed I in fact wondered if the filtering function for an “inherit query” was intended or not and whether this had accidentally slipped out of version 6.0.2
I really hope not because as I say, there is considerable functionality embedded in the option to filter the loop with custom taxonomies etc. but still respect the template (category, archive etc). It allows you to do a great deal with custom category pages and archives.
I hope this at least conveys some sense of the issues to you and those who are more technically capable of seeing through these issues.
… On 12 Sep 2022, at 08:45, Carolina Nymark ***@***.***> wrote:
Hi, are you able to you provide testing instructions that does not involve third party plugins (ACF)?.
—
Reply to this email directly, view it on GitHub <#44041 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/A27ZNSSP5B4ND3KH2JBRBELV53NQPANCNFSM6AAAAAAQJDRRN4>.
You are receiving this because you authored the thread.
|
Dear Carolina,
Were you able to find any evidence of the issue I reported?
Thank you
… On 12 Sep 2022, at 08:45, Carolina Nymark ***@***.***> wrote:
Hi, are you able to you provide testing instructions that does not involve third party plugins (ACF)?.
—
Reply to this email directly, view it on GitHub <#44041 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/A27ZNSSP5B4ND3KH2JBRBELV53NQPANCNFSM6AAAAAAQJDRRN4>.
You are receiving this because you authored the thread.
|
No. You can enable notifications / subscribe to be notified when there are any replies to this issue. |
After a bit of investigation, there were a handful of Query Loop changes made in 6.0.2 here: https://github.com/WordPress/gutenberg/commits/wp/6.0. @gziolo @draganescu would you guys have any insight into this issue? |
Howdy @sb726 I think this is the bit that changed. You were using a weird behavior which more recent versions of the query block attempt to fix: once you set inherit query it will only use the global query on that page, so all settings get ignored. |
Many thanks @draganescu @ndiego for this reply. This was actually my concern. The "weird behaviour" was actually very useful. It allowed you to use a global query (e.g. a category query) but to then filter this according to whatever custom taxonomy you happened to be using. In principle, to be able to organise a category page, index page etc. according to other custom taxonomies or even tags seems like a pretty standard thing to do. It enables you, for example, to cross filter a category page and have different blocks for different parts of any custom taxonomy -- really useful. Is there now any way to achieve this same filtering directly within the query block or is it necessary to write custom PHP queries? I hope that makes sense. Even more, I hope the filtering functionality will be reintroduced in to the query block but perhaps in a more obvious way allowing for global queries but with added filtering for taxonomies, tags etc. |
@sb726 this sounds interesting. Could you please offer a concrete example of:
I am not sure I understand what this means in practice.
Since query blocks are self contained in terms of their settings, what is wrong with using one query block that follows the global query and another one with a custom query in the same page? |
Please add filter by custom field in the Query Loop block. |
Without digging deep, I think that the difference you're describing and I agree with what @draganescu says. That was a bug where we retained some query attributes even if we had set to Having said that, I understand that folks have different use cases, and in 6.1 it will be easier to extend Query Loop in some ways. The documentation will be enhanced really soon, but the first PR got merged, that provides more info about that. I hope that's helpful to @sb726 and @muhammadharoonbro for asking about the custom field. |
Cool! I was not even aware of the cool extensibility options (via variations) that are upcoming and so well documented now. @sb726 do you think we can close this now? |
(I have tried to upload screenshots but for some reason this is not currently working so please see descriptions) I hope this makes the use case clear. This refers to a category template. First you have to switch off inherit query from template (see below) [image not loading: In the editor go to a category template with a query block. Click on the query block and view settings. Click off "inherit query from template"] Next, with the filtering options revealed, you can filter custom taxonomies etc. [image not loading: In the settings panel that is revealed after step one above you have options to set the post type, order posts, filter categories, tags and custom taxonomies. As a use case, set the custom taxonomy to taxonomy 1] Finally switch "inherit query from template" back on. The query block will reflect the relevant category from the category global query but it will also filter for the custom taxonomy. This works in 6.01 but not 6.02
The problem with this is that in my use case and I guess that of many others the custom taxonomy cuts across the category. In effect, the custom taxonomy is a subset of the category. If I allow a block with the global query I get posts from a single category but every custom taxonomy. This completely destroys the functionality. If I instead use a custom query (in 6.02) I get the correct custom taxonomy but again for every category. Again this destroys the functionality. In effect I wish to execute a SQL query for a single query block along the lines of (bearing in mind that the global query is on a category template): SELECT * FROM POSTS WHERE CATEGORY = CATEGORY 1 Different blocks would reference different custom taxonomy terms. This query was possible in the query block in 6.01. It does not seem to be possible in 6.02. I sense that @ntsekouras understands the issue and has determined that the behaviour I was using is a bug. However, I am not clear from the response whether the functionality I describe will be reintroduced into the latest version of wordpress. Just to be clear. I do not think this is particularly weird behaviour nor a minor use case. Being able to filter the global query for a category etc. according to custom taxonomies and tags seems like a pretty basic and fundamental thing you might want to do for a wide range of websites. I need to read the linked article in more depth to understand what extensions may have been made to the query loop but in short, if the above SQL query is not possible within the current query loop it would be really useful to introduce this functionality or explain how it can be achieved. |
No. I am not able to fetch results with same custom field value in post_meta table. Please tell me in details because Query loop block have no such option to do so. |
@sb726 if I understand correctly, your use case is not a standard
@muhammadharoonbro there is no filter for post meta in Query Loop inspector controls and there will not be one for various reason, like because there is no support for post meta in REST API. This is what the docs will try to help with, but in general a really customized extended Query Loop also needs PHP handling for modifying the query, the REST API etc.. |
Thanks for the well documented explanation @sb726 🙇🏻 Juts wanted to make sure this is visible: the answer to the above is in the comment from @ntsekouras
|
@ntsekouras I think my use case might be "reasonably" standard. Take a category page (which could be issues of a magazine, pages of a clothes catalogue, types of books etc.) and divide that category page up according to some custom taxonomy. You need the inherit query property so that the right category page appears when clicking on a category link. But you might also need to further filter or subdivide those categories. That you could do this in 6.01 was very useful. I do not fully understand the tax_relation point but I see that #24934 may address the points I am raising. Just to be clear: so long as you can use inherit Query Loop AND add a custom taxonomy (which I think is what the tax_relation point refers to) then my point is addressed. Anyway I think this is probably all that can be said. I understand that these points are being taken on in the workflow elsewhere so I am happy @draganescu to close this discussion now if need be. Thanks for changing the title which I think now better addresses the issues being raised. I look forward to the new updates. |
Description
After upgrading from 6.0.1 to 6.0.2 the filtering functionality within the query loop on the editor stopped working when trying to filter category pages according to a custom taxonomy
Step-by-step reproduction instructions
Using a child theme of Blockbase the following worked with version 6.0.1 but not version 6.0.2
Create a custom taxonomy using advanced custom fields (e.g. A, B, C)
Create one or more categories (e.g. 1, 2, 3)
Create several posts with a mix of different categories and identifiers from the custom taxonomy (e.g., 1A, 1B, 2A, 2C...)
Use a category template and within the template editor create several different query loop blocks to display different parts of the taxonomy, e.g., one query loop for A types, one for B types etc
For example, in the first query loop block, within the editor click off "inherit query from template" in settings to reveal filters. Identify the taxonomy created above and filter to A. Click back on "inherit query from template"
Repeat for the second query loop block. Now choose B from within the taxonomy.
Expected behaviour (which worked in 6.0.1):
When clicking on a category link to be taken to the category page (from the template just created) clicking on category 1 would reveal only category 1 A types in the first query loop block, only category 1 B types in the second and so on.
Moving to a category 2 page the A and B blocks changed to category 2 posts
After updating to 6.0.2 the filtering did not work. All query loop blocks showed all posts and there is no filtering by taxonomy. Clicking off "inherit query from template" solved the taxonomy problem. However, categories do not then work as expected.
Rolling back to 6.0.1 the filtering worked again.
I noted that 6.0.2 made some (unrelated?) changes to the query loop block and its filters.
Screenshots, screen recording, code snippet
No response
Environment info
6.0.2
Blockbase child theme
Mac 16 (2019)
Safari 15.6.1
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
No
The text was updated successfully, but these errors were encountered: