• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Programmatically creating a repeater block.

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Genesis Custom Blocks › Programmatically creating a repeater block.

This topic is: not resolved

Tagged: development, Genesis Custom Blocks

  • This topic has 0 replies, 1 voice, and was last updated 3 weeks, 3 days ago by bishopdz.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • April 29, 2022 at 8:36 am #505157
    bishopdz
    Participant

    Hello, my development team is using Genesis Custom Blocks to programmatically create blocks that are stored and reused in our git repo. I am trying to code a repeater block but I am stuck because I have not been able to find any examples of this. Here is what I have tried that seems syntactically correct.

    1:
    <?php

    use function Genesis\CustomBlocks\add_block;

    function add_fees_block() {

    // One long array with lots defined.
    add_block(
    'fees',
    array(
    'title' => 'Fees Block',
    'category' => 'common',
    'icon' => 'account_circle',
    'fields' => array(
    'repeater' => array(
    'name' => 'repeater',
    'label' => 'Repeater',
    'control' => 'repeater',
    'type' => 'text',
    ),
    ),
    ),
    );
    }
    add_action( 'genesis_custom_blocks_add_blocks', 'add_fees_block');

    2:
    <?php

    use function Genesis\CustomBlocks\add_block;

    function add_fees_block() {

    // One long array with lots defined.
    add_block(
    'fees',
    array(
    'title' => 'Fees Block',
    'category' => 'common',
    'icon' => 'account_circle',
    'fields' => array(
    'repeater' => array(
    'name' => 'repeater',
    'label' => 'Repeater',
    'control' => 'repeater',
    'field' => 'text',
    ),
    ),
    ),
    );
    }
    add_action( 'genesis_custom_blocks_add_blocks', 'add_fees_block');

    3:
    <?php

    use function Genesis\CustomBlocks\add_block;

    function add_fees_block() {

    // One long array with lots defined.
    add_block(
    'fees',
    array(
    'title' => 'Fees Block',
    'category' => 'common',
    'icon' => 'account_circle',
    'fields' => array(
    'repeat' => array(
    'name' => 'repeat',
    'label' => 'Repeater',
    'control' => 'repeater',
    'fields' => array(

    'text' => array(
    'name' => 'text',
    'label' => 'Text',
    'control' => 'text',
    ),
    ),
    ),
    ),
    ),
    );
    }
    add_action( 'genesis_custom_blocks_add_blocks', 'add_fees_block');

    I am unsure if it is even possible but it would help us a lot.
    Thank you for your time.

  • Author
    Posts
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Log In

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2022 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble