If you want to adjust the HTML of a Core block, one option is to add a filter on the render_block hook. This allows you to use PHP to modify the HTML output, so you don’t have to set up a whole Webpack setup and use newer JS. If you place this in the (child) theme, this will also allow the site owner to automatically swap back to normal Gallery block markup if they switch themes, so non-Bootstrap themes won’t break the block.
The downside is, the filter runs after WordPress has already retrieved the content, so you’re looking at slightly longer processing times of the final markup. This shouldn’t be too big of an issue for most sites, especially if you have some kind of caching set up.
You can find documentation on render_block on the WP Developer site.
Related Posts:
- Add colors to existing color palette without replacing it
- Gutenberg – editor-font-sizes in functions not working
- create-guten-block in wordpress theme?
- Correct way to make a custom block theme responsive
- Full site editing templates folder vs block-templates
- How to add multiple custom blocks in custom WordPress theme using create-block?
- Full Site Editing, Block Theme, Gutenberg, Site Editor
- Sizing screenshot.png without losing aspect ratio
- Do I actually need to link my theme’s style.css in the theme files
- CSS classes for theme
- My child theme doesn’t work Error: “The parent theme is missing. Please install your parent theme”
- Page template in two level deep folder
- Edit srcset and sizes attributes in Gutenberg image, cover and gallery – blocks
- Theme file for all pages that are a child of a specific page
- Use of undefined constant FS_CHMOD_DIR – assumed ‘FS_CHMOD_DIR’
- How to show next Post Thumbnail image in WordPress using current post id
- First post of each category
- create blocks programmtically on theme activation
- Why use while over if in single wordpress posts?
- WordPress website loads but is not displayed until page scrolled
- Create a theme by combining a parent and a child theme
- Theme Customizer not loading
- How to add oEmbed support to my theme?
- Single Theme folder for Multiple WordPress
- How Can I Create a List of Values to Be Iterated Through via WordPress Customization API?
- Cutomize Colors utility: How to add more configurable colors to a theme
- If I build a custom theme, will it update?
- Recommended tools for Theme Development with SASS [closed]
- What tags should be used for themes to show the type of layout?
- What are non-printable characters doing in my theme?
- Custom button block doesn’t work
- WordPress post arrangement using post_class
- How can I let templates choose which stylesheets are enqueued?
- Which file handles the block latest posts, I want to examine excerpt handling
- Lightweight framework [closed]
- How to edit my theme for full width?
- What VSCode extensions are there for working with block themes? [closed]
- What is the “correct” way to add hooks or similar PHP behavior to a blocktheme?
- Not able to select width of blocks inside of cover block
- Edit footer via customizer
- gutenberg add classes to list items
- How do you replace content generated by custom fields with custom blocks in Block Editor?
- Echo all category names, apart from one
- Custom Blocks as part of a theme
- Admin: sub menu doesnt display under apperance when activate my themes
- Does code in function.php differ from theme to theme
- Block editors annoying warnings
- Create a child theme from multiple themes
- Theme not showing up
- Are seven additional image sizes are too many?
- How can I use the WordPress Loop and Pagination in multiple instances but different scenarios throughout my site?
- registering a global template wordpress 6.0
- How to add InnerBlock multiple times in the same block
- Copying the theme style files and images to duplicate the website but with a difference
- I have WordPress setup on primary domain, how do I set it up on its subdomain using the same database?
- How to set Post meta-box defaults based on the choices made by user in Customizer?
- Theme Action to hook for one time only function [duplicate]
- How do I include a partial from a directory below a wordpress theme directory?
- How to remove permalinks links presents in each page of my site?
- first excerpt fine, subsequent post excerpts shift to the right instead of displaying vertically [closed]
- HTTP Error when uploading images over specific dimensions
- Why is the `if else` not working?
- showing all recent posts in theme
- Is there a way to serve different resolution images to different devices?
- iPad WordPress theme?
- custom Background not showing after upgrade?
- Rolling your own WordPress Themes
- How to make a function occurs for one time?
- List categories of a post hierarchically?
- How to render block editor in wp-admin custom pages programmatically
- Custom Enfold theme tab layout not compatible with WPML
- Attribute form NumberControl doesn’t update when I update page before it lose its focus
- Theme: dropdown hover menu not showing up in IE/Edge
- Problem with pagination link (error 404)
- how to ensure responsiveness in wp themes? [closed]
- How to test another theme in a live WordPress website instead of live preview?
- home is not working in wordpreess
- Is there a way to create sections under “Colors” panel in the Theme Customizer?
- Local theme changes upload on server but theme changes not showing
- WordPress Custom font not found
- Can’t upload images on new theme
- New created Theme leads to malfunctioning Xampp Apache –> functions.php is cause
- WordPress Blog Page displaying nothing
- Magnific Popup – Add Caption to Images
- Why do WordPress developers use so many opening and closing PHP tags when developing themes? [duplicate]
- Safe way to echo wp_trim_words
- How can I demonstrate themes well?
- Why the slideshow is not shown in my theme?
- How to update my own theme?
- WordPress custom jquery not found
- Custom link color or stylesheets
- What is The Best Way to Make Parallax header effect for wordpress theme ?? pure CSS or using JavaScript? [closed]
- How to remove proudly created by WordPress in theme?
- Roll my own theme or customize an existing one [closed]
- Why do some sites show themes/”themename” as the only theme?
- What is the point of using the front-page.php template? [closed]
- Why is my Toggle field not showing in Gutenberg?
- How can a theme define which settings for blocks are available in the block editor?
- Export WordPress theme with modifications for other site
- how to combine wordpress and front framework