Skip to content
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

Unable to add a class to query block list item #41441

Open
coreyworrell opened this issue May 30, 2022 · 3 comments
Open

Unable to add a class to query block list item #41441

coreyworrell opened this issue May 30, 2022 · 3 comments
Labels
[Block] Post Template Affects the Post Template Block [Type] Enhancement A suggestion for improvement.

Comments

@coreyworrell
Copy link
Contributor

coreyworrell commented May 30, 2022

What problem does this address?

Pretty much all blocks allow a custom CSS class name to be provided. But query block does not allow you to set a list item class. This can be very useful for using utility classes and such. Currently you can add classes to the query block, the post template wrapper, and then each block inside, but not the actual direct child of the post template block, the <li> element.

Screenshot from 2022-05-30 10-55-14

@justintadlock justintadlock added [Type] Enhancement A suggestion for improvement. [Block] Post Template Affects the Post Template Block labels Jun 7, 2022
@justintadlock
Copy link
Contributor

Note: It's possible to do this via the post_class hook on the front end but not via the UI: https://developer.wordpress.org/reference/hooks/post_class/

@jethrodesign
Copy link

jethrodesign commented Aug 22, 2022

Was just trying to do this myself. Assumed adding a class in Advanced area of Post Template block would add the class to each individual post (<li> item), not the parent container, since the Post Template block is the direct container of all of the block elements that can be added and displayed for each individual post item.

In my case, wanted to be able to animate each post item (e.g each fades in). This requires adding specific class(es) to whichever element you want to animate. Would be easier to do in editor than programmatically behind the scenes, especially if a client needed this option...

@coreyworrell
Copy link
Contributor Author

I'm not versed enough in the code, but this may be a simple addition and could really help with styling query loops. Being able to define classes for specific loops in the UI is always preferable over code modifications which are less flexible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Template Affects the Post Template Block [Type] Enhancement A suggestion for improvement.
3 participants