-
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
Template for specific category: only load posts from that category in post template block #43699
Template for specific category: only load posts from that category in post template block #43699
Conversation
If the query block is part of a template we should consider whether it's a template for a category.
Size Change: +3.92 kB (0%) Total Size: 1.25 MB
ℹ️ View Unchanged
|
const categoryIds = categories | ||
?.filter( ( { slug } ) => slug === targetSlug ) | ||
.map( ( { id } ) => id ); | ||
query.taxQuery = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is useful, though we need to make it so any taxonomy works by default. I'm thinking on tags but also any 3rd party taxonomies (e.g.: product categories that Woo uses, etc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, it's behaving as expected from a UX perspective, so I'm approving on that account.
It would be nice to do something similar with the Archive Title block as a follow-up, since this is a bit sub-optimal 😅
Something else we'll need to think about soon: As we implement this behaviour for other templates (taxonomies, specific posts / pages, etc), it seems reasonable that users will expect to fluidly move between editing template/content. At the moment Queries are locked.
I don't think direct manipulation is the way to go (there still needs to be some friction), but I think some more design exploration is warranted. Perhaps something like #43608 can inform the direction. cc @jasmussen.
You're referring to the fact that you see real content, but you cannot (or should not) edit it? Yes, I think there needs to be some indication that it is shown but not meant to be editable. Outside of bigger click-through layers and edit buttons, we could potentially — judiciuosly — apply |
In this circumstance it's probably fine to make it editable (maybe even by direct manipulation, I shouldn't be so hasty). But at the moment it is not at all which feels a bit awkward. If you see a typo you need to go all the way to the post editor to fix it.
Absolutely. I was mostly connecting a dot, and hopefully trying to get ahead of something that I anticipate will be requested fairly soon after these features are merged. |
What
This PR makes the post template block to load only the posts from a specific category when the 1) the query block is set to inherit the filters from the template and 2) the user is editing the template of a specific category.
Why
We want to present the users with the contextual data they're editing. Part of #41947
How?
This PR continues the work started at #27128 (allow query to inherit from template) and #27972 (introduce
templateSlug
data to decouple from edit-site).It inspects the value of the existing
templateSlug
and if it'scategory-<slug>
it uses that info to prepare the query.Testing Instructions
Gravacao.de.ecra.a.partir.de.30-08-2022.12.13.24.webm