-
Notifications
You must be signed in to change notification settings - Fork 7
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
Building dynamic attachment templates in block themes #199
Comments
Example repository: https://github.com/justintadlock/dynamic-attachments I'll probably begin writing the tutorial on this one next week. |
I have started writing this here: https://docs.google.com/document/d/1VRHL7Pubz90UH14pdNBxI4HYmpxxnepDX9grflCwm64/edit?usp=sharing |
This one is ready for its first review: https://docs.google.com/document/d/1VRHL7Pubz90UH14pdNBxI4HYmpxxnepDX9grflCwm64/edit?usp=sharing |
1st review done. @justintadlock I left a few minor comments, mostly tone and filler. I appreciate this post very much, as it demonstrates clearly, that PHP can be used to while creating block themes and prior solutions can be integrated. |
Thank you for the review, @bph. As always, great feedback. I had a couple of in-comment questions, but I'm moving this to needs 2nd review since the other edits have been resolved. |
@justintadlock I've just finished a 2nd review of your piece. Some minor copy edits and small nitpicks to consider. Looks good otherwise. 👍 |
Social copy:
|
Social post scheduled. |
Discussed in #192
Originally posted by justintadlock December 19, 2023
Block themes support
attachment.html
templates, but WordPress is not very "smart" about handling the output of media for attachment views. At the moment, there are no dynamic Image, Audio, and Video blocks that automatically pick up the current attachment media file on the front end.Yes, attachments views are now disabled by default for new WP installs (as of 6.4?), but there are still many use cases where attachment templates are needed.
Typically, I don't like to propose topics for the Dev Blog that are outside the standards of theme dev, but this is one of those situations that requires a bit of hacking to make things work as well as they did in classic. That's unfortunate, but this is a missing piece of block theme dev with no instructions/docs (AFAIK) on the best way to handle this.
I'm proposing a tutorial on how to filter the Post Content block for attachment views to insert a sort of dynamic template partial/pattern that allows theme authors to control the output of attachment pages.
I have a working example in my own theme that I could break down for this tutorial:
The text was updated successfully, but these errors were encountered: