• 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 6 replies, 6 voices, and was last updated 3 weeks, 2 days ago by samneerha.
Viewing 7 posts - 1 through 7 (of 7 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.

    June 11, 2022 at 11:42 am #505397
    samneerha
    Participant

    TechBigis
    The Hub of Premium Apps and Games
    With our website TechBigis, you can effortlessly search and download millions of apps and games for free, whether they are free or premium versions. Aside from that, you can find helpful information and Modified Apps or Games on Android, iOS, Windows, and many other things every day.

    June 22, 2022 at 3:03 am #505456
    shahzain1
    Participant

    Getinshotproapk
    Get the Latest Updates and News about InShot.
    With Our Website Getinshotproapk, You can search and download the best video and photo editing app here with the latest news and update version. This app is totally free and available in different variants like Android, IOS, PC, and Windows so chose as per your requirement and download the inshot app.

    August 7, 2022 at 11:25 am #505647
    MB03043666
    Participant

    The game has everything you could ever want, from unlimited money to chatting with other players online and much more. You can now play this game in multiplayer mode if you want, or offline if you prefer Then Check out this game Ludo Talent Mod Apk

    August 23, 2022 at 11:30 am #505722
    Michaelmati
    Participant

    ML Injectors Mobile Legend Updates and News. TheNoobGamerz offers the latest news and updated versions of the best video games like MLBB. Download the latest ml skin injector as per your requirement and choose between Android, IOS, Windows, and PC.

    October 10, 2022 at 3:53 am #505965
    rebecca7b
    Participant

    Let’s first create our field. This field can be used however you want, but I will assume that we are working on a meta box so I am getting the field data with the function get_post_meta.
    <?php
    // Assuming we are setting a field inside a metabox
    $field_data = get_post_meta( $post_id, 'field_data', true );

    ?>

    <label for="field_data">
    <?php _e( 'Field Name', 'yourtextdomain' ); ?>
    </label>
    <div id="field_data">
    <?php foreach( $field_data as $field ) { ?>
    <div class="field-group">
    <input type="text" name="field_data[] value="<?php echo $field; ?>" />
    <button type="button" class="button button-secondary field-data-remove">X</button>
    </div>
    <?php } ?>
    </div>
    <button type="button" id="field_data_add" class="button button-primary">Add</button>

    January 17, 2023 at 4:00 am #506592
    samneerha
    Participant

    We are a registered trademark established in 2015; in these years, we have had more than 51000+ happy customers worldwide. Our site is the only official and authorized to sell BlackPods 3

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 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

© 2023 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