Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Piklist Widget with Group Fields
<?php
piklist('field', array(
'type' => 'text'
,'field' => 'title'
,'label' => 'Title'
));
piklist('field', array(
'type' => 'group'
,'field' => 'chooseus'
,'columns' => 12
,'add_more' => true
,'fields' => array(
array(
'type' => 'file'
,'field' => 'image'
,'label' => __( 'Image', 'sf')
,'columns' => 12
,'options' => array(
'basic' => false
,'advance' => false
)
)
,array(
'type' => 'text'
,'field' => 'title'
,'label' => __('Title', 'sf')
,'columns' => 4
,'attributes' => array(
'placeholder' => 'Google'
)
)
,array(
'type' => 'textarea'
,'field' => 'description'
,'label' => __('Description', 'sf')
,'columns' => 8
),
)
));
//// Output File ##############################################
<?php
/*
Title: Why Choose Us
*/
echo $before_widget;
echo $before_title;
echo $settings['title'];
echo $after_title;
$chooseus = $settings['chooseus'];
$length = $chooseus[title];
$length = count($length);
echo '<div class="main-box">';
for ( $i=0; $i < $length; $i++ ) {
$title = $chooseus['title'][$i];
$description = $chooseus['description'][$i];
$image = ( $i == 0 ) ? $chooseus['image'][$i] : $chooseus['image'][$i][1];
echo '<div class="box1">
<img src="'.wp_get_attachment_url($image).'" alt="">
<div class="right-set">
<h1>'.$title.'</h1>
<p>'.$description.'</p>
</div>
</div>';
}
echo '</div>';
echo $after_widget;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.