Skip to content

Instantly share code, notes, and snippets.

Last active May 1, 2019 01:07
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Add Custom Attributes to Core Gutenberg Blocks. View full tutorials at
* WordPress Dependencies
const { addFilter } = wp.hooks;
* Add custom attribute for mobile visibility.
* @param {Object} settings Settings for the block.
* @return {Object} settings Modified settings.
function addAttributes( settings ) {
//check if object exists for old Gutenberg version compatibility
if( typeof settings.attributes !== 'undefined' ){
settings.attributes = Object.assign( settings.attributes, {
type: 'boolean',
default: true,
return settings;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment