To add the repeater fields in the WordPress Theme Customizer first download the given files from the link here and add them to the theme folder.
Then include the downloaded file from the functions.php file
<?php require get_template_directory() . '/customizer-repeater/functions.php'; ?>
Add the below code to the functions.php
<?php function sets_alwindor_aparts($wp_customize){ $wp_customize -> add_section('aparts_customizer', array( 'title' => __('TITLE_OF_THE_CUSTOMIZER','alwindor'), 'description' => '' )); $wp_customize->add_setting( 'customizer_repeater_aparts', array( 'sanitize_callback' => 'customizer_repeater_sanitize' )); $wp_customize->add_control( new Customizer_Repeater( $wp_customize, 'customizer_repeater_aparts', array( 'label' => esc_html__('Item','customizer-repeater'), 'section' => 'aparts_customizer', 'priority' => 1, 'customizer_repeater_title_control' => true, 'customizer_repeater_text_control' => true, 'customizer_repeater_icon_control' => true, 'customizer_repeater_image_control' => true, 'customizer_repeater_subtitle_control' => false, 'customizer_repeater_link_control' => false, 'customizer_repeater_shortcode_control' => false, 'customizer_repeater_repeater_control' => false ) ) ); } add_action('customize_register','sets_alwindor_aparts'); ?>
Use the below code to the templates file to get the field added in the customizer.
<?php $customizer_repeater_example = get_theme_mod('customizer_repeater_example'); /*This returns a json so we have to decode it*/ $customizer_repeater_example_decoded = json_decode($customizer_repeater_example); foreach($customizer_repeater_example_decoded as $repeater_item){ echo $repeater_item->icon_value; echo $repeater_item->text; echo $repeater_item->link; echo $repeater_item->image_url; echo $repeater_item->choice; echo $repeater_item->title; echo $repeater_item->subtitle; echo $repeater_item->shortcode; /*Social repeater is also a repeater so we need to decode it*/ $social_repeater = json_decode($repeater_item->social_repeater); foreach($social_repeater as $social_repeater){ echo $social_repeater->link; echo $social_repeater->icon; } } ?>