Add Favorite Buttons to WordPress Gallery Block Images

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

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 :

  1. Copy and paste the PHP code to your child themes functions file.
  2. Upload the file named gallery.js to your child theme folder.
  3. 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

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.

Download Folder

Related Tutorials

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.