Create Block

You can create custom blocks with output HTML or PHP. Also, blocks may work with custom meta fields, that will be available from the PHP to output in your theme code.

  • Navigate to WordPress Admin > Lazy Blocks
  • Click Add New button

Block Edit Screen

On this screen, you can configure your block.

Main section

  • Controls – controls to manage your block options. The full description read on this page
  • Code – custom HTML + Handlebars syntax or PHP, which you can use to output data from block controls. See examples page for more info.
    • Frontend – code, that will be shown on your site content, when you use your block. Keep it empty if you don’t want to output anything (if you need to use this block as custom meta field)
    • Editor – code, that will be shown in the editor on your block
    • Single output code for Frontend and Editor – check if you don’t want to split code for frontend and editor and use a single code for both places
    • Output Method – select HTML + Handlebars or PHP code output method
    • Show block preview in editor – select the condition when block preview will be visible in Gutenberg editor

Secondary section

  • Title – display block name, that will be shown in the blocks inserter
  • Slug – unique string that identifies your block. A block name can only contain lowercase alphanumeric characters and dashes and must begin with a letter
  • Icon – help users identify your block. Available only Dashicons.
  • Category – help users find your block. There are some default categories, but you also able to create your own category simply by pressing Enter
  • Description – short description for your block, that will be shown in the block inspector
  • Keywords – block aliases that help users discover it while searching. For example, an ‘image’ block could also want to be discovered by ‘photo’. It is only allowed to add as much as three terms per block.
  • Supports
    • Multiple – allow inserting block multiple or one time only (when disabled)
    • Class Name – adds a field to define a custom class name for the block’s wrapper
    • Anchor – adds a field to define an id for the block and a button to copy the direct link
    • Show in Blocks Inserter – by default, all blocks will appear in the Gutenberg inserter. Disable this option to hide block so it can only be inserted programmatically
  • Align – adds block controls that allow changing the block’s alignment. By default added ‘wide’ and ‘full’ alignments, but make sure your theme supports it
  • Condition – post types in which this block will be showed. If no post types selected, the block will be shown everywhere
Was this page helpful?