Last active
January 17, 2023 14:46
-
-
Save humayunahmed8/14774b6c3bc1e6410438d7feb555f2a2 to your computer and use it in GitHub Desktop.
Kirki repeater field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new \Kirki\Field\Repeater( | |
[ | |
'settings' => 'repeater_setting_4', | |
'label' => esc_html__( 'Works Settings', 'kirki' ), | |
'section' => 'section_id', | |
'row_label' => [ | |
'type' => 'field', | |
'value' => esc_html__( 'Your Custom Value', 'kirki' ), | |
'field' => 'works_title', | |
], | |
'button_label' => esc_html__( 'Add new works', 'kirki' ), | |
'default' => [ | |
[ | |
'works_image' => get_template_directory_uri() . '/assets/img/svg/strategy-icon-1.svg', | |
'works_title' => 'Download', | |
'works_details' => 'Type feature description here in the sub paragraph 1', | |
'works_color' => '#ffffff', | |
'select_icon' => 'option-1', | |
], | |
[ | |
'works_image' => get_template_directory_uri() . '/assets/img/svg/strategy-icon-2.svg', | |
'works_title' => 'Bank Account', | |
'works_details' => 'Type feature description here in the sub paragraph 2', | |
'works_color' => '#ffffff', | |
'select_icon' => 'option-2', | |
], | |
[ | |
'works_image' => get_template_directory_uri() . '/assets/img/svg/strategy-icon-3.svg', | |
'works_title' => 'Choose Coins', | |
'works_details' => 'Type feature description here in the sub paragraph 3', | |
'works_color' => '#ffffff', | |
'select_icon' => 'option-3', | |
], | |
], | |
'fields' => [ | |
'select_icon' => [ | |
'type' => 'select', | |
'label' => esc_html__( 'Select Icon', 'kirki' ), | |
'choices' => [ | |
'1' => esc_html__( 'Icon 1', 'kirki' ), | |
'2' => esc_html__( 'Icon 2', 'kirki' ), | |
'3' => esc_html__( 'Icon 3', 'kirki' ), | |
], | |
'default' => '', | |
], | |
'works_image' => [ | |
'type' => 'image', | |
'label' => esc_html__( 'Works Image', 'kirki' ), | |
], | |
'works_title' => [ | |
'type' => 'text', | |
'label' => esc_html__( 'Works Title', 'kirki' ), | |
'default' => '', | |
], | |
'works_details' => [ | |
'type' => 'textarea', | |
'label' => esc_html__( 'Works Details', 'kirki' ), | |
'default' => '', | |
], | |
'works_color' => [ | |
'type' => 'color', | |
'label' => esc_html__( 'Works Color', 'kirki' ), | |
'default' => '', | |
], | |
], | |
'choices' => [ | |
'limit' => 4 | |
] | |
] | |
); | |
// example one | |
<?php | |
$works = get_theme_mod('repeater_setting_4'); | |
?> | |
<!-- Single Working Strategy --> | |
<?php foreach ($works as $work) { ?> | |
<div class="col-lg-4 col-md-4 col-sm-12"> | |
<div class="single-working-strategy"> | |
<a href="#"><img src="<?php echo $work['works_image'];?>" alt="strategy icon one"></a> | |
<h4><?php echo $work['works_title'];?></h4> | |
<p><?php echo $work['works_details'];?></p> | |
</div> | |
</div> | |
<?php }?> | |
// example two | |
<?php | |
$works = get_theme_mod('repeater_setting_4'); | |
?> | |
<!-- Single Working Strategy --> | |
<?php foreach ($works as $work) { ?> | |
<div class="col-lg-4 col-md-4 col-sm-12"> | |
<div class="single-working-strategy" style="background-color: <?php echo $work['works_color']; ?>"> | |
<a href="#"><img src="<?php echo get_template_directory_uri() . '/assets/img/svg/strategy-icon-'.$work['select_icon'].'.svg' ?>" alt="strategy icon one"></a> | |
<h4><?php echo $work['works_title'];?></h4> | |
<p><?php echo $work['works_details'];?></p> | |
</div> | |
</div> | |
<?php }?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment