Skip to content

Instantly share code, notes, and snippets.

@azizultex
Last active February 7, 2019 07:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azizultex/8ca33e8844a8048221d4 to your computer and use it in GitHub Desktop.
Save azizultex/8ca33e8844a8048221d4 to your computer and use it in GitHub Desktop.
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