Created
April 17, 2024 11:17
-
-
Save thoriqmacto/30e6066a3a408c9b86ece8cb1338b7e4 to your computer and use it in GitHub Desktop.
Wordpress block variation registration code for post-featured-image to include caption automatically.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define the custom block variation | |
wp.blocks.registerBlockVariation( | |
'core/post-featured-image', // Base block type | |
{ | |
name: 'sotp/post-featured-image', // Variation name | |
title: 'Post Featured Image + Caption', // Variation title | |
description: 'Displays the post\'s featured image with caption.', // Variation description | |
attributes: { | |
namespace: 'sotp_post_featured_image', // Custom attribute namespace | |
className: 'sotp-post-featured-image' // Custom class name | |
}, | |
scope: ['inserter'] // Block variation is available only in the inserter | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment