The code in this download adds the favorites button to the gallery images block when using Gutenberg blocks. You can use the code to add :
- Favorite, Like, Love, Bookmark and Wishlist buttons
- Buttons with a count
- Your own custom button markup
![](https://wpsites.net/wp-content/uploads/2024/06/Gallery-Block-480x300.png)
![](https://wpsites.net/wp-content/uploads/2024/06/WordPress-Gallery-with-Favorite-Buttons-480x300.png)
Demo Video
Shows the buttons added to each gallery image when using the gallery block native to WordPress when using the block editor, Gutenberg.
Works in any WordPress theme.
Installation
There’s 3 steps :
- Copy and paste the PHP code to your child themes functions file.
- Upload the file named gallery.js to your child theme folder.
- Install the favorites for WordPress plugin by Kyle Phillips and configure the settings to apply to media. Go to Favorites Settings > Display and Post Types > Enabled Favorites for : Media
![](https://wpsites.net/wp-content/uploads/2024/06/plugin-settings.png)
The download folder also includes CSS to position the button over the image. If not used, your buttons will display after the image without any gap.
Was This Tutorial Helpful?