/* ------------------- shortcode :-1 ------------------ */
/* Product Single Page What does it do Shortcode*/
function product_single_what_does_it( $atts )
{
ob_start();
while(have_rows('product_features')):
the_row();
?>
<div class="col-sm-4 col-xs-12 text-center">
<div class="product-what-does-it-box">
<div class="product-what-does-it-image">
<img src="<?php the_sub_field('features_icon');?>" alt="Image" />
</div>
<div class="product-what-does-it-desc">
<p><?php the_sub_field('features_text'); ?></p>
</div>
</div>
</div>
<?php
endwhile;
$output = ob_get_contents();
ob_end_clean();
return $output;
}
add_shortcode( 'product_single_what_does_it', 'product_single_what_does_it' );
/* Product Single Page What does it do Shortcode*/
function product_single_what_does_it( $atts )
{
ob_start();
while(have_rows('product_features')):
the_row();
?>
<div class="col-sm-4 col-xs-12 text-center">
<div class="product-what-does-it-box">
<div class="product-what-does-it-image">
<img src="<?php the_sub_field('features_icon');?>" alt="Image" />
</div>
<div class="product-what-does-it-desc">
<p><?php the_sub_field('features_text'); ?></p>
</div>
</div>
</div>
<?php
endwhile;
$output = ob_get_contents();
ob_end_clean();
return $output;
}
add_shortcode( 'product_single_what_does_it', 'product_single_what_does_it' );
💨 [Boostrap Custom Accordian with ACF Field value(function.php)]
/* New Product Single page */
add_shortcode( 'product_faq', 'product_faq_func' );
function product_faq_func( $atts ) {
ob_start();
if( have_rows('product_faq') ):
// Loop through rows.
?>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<?php
while( have_rows('product_faq') ) : the_row();
// Load sub field value.
$product_question = get_sub_field('product_question');
$product_answer = get_sub_field('product_answer');
$id = rand();
?>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="<?php echo $id; ?>">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse<?php echo $id; ?>" aria-expanded="true" aria-controls="collapse<?php echo $id; ?>">
<i class="more-less glyphicon glyphicon-plus"></i>
<?php echo $product_question; ?>
</a>
</h4>
</div>
<div id="collapse<?php echo $id; ?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="<?php echo $id; ?>">
<div class="panel-body">
<?php echo $product_answer; ?>
</div>
</div>
</div>
<?php
// End loop.
endwhile;
?>
</div>
<?php
endif;
$output = ob_get_contents();
ob_end_clean();
return $output;
}
/* New Product Single page */
add_shortcode( 'product_faq', 'product_faq_func' );
function product_faq_func( $atts ) {
ob_start();
if( have_rows('product_faq') ):
// Loop through rows.
?>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<?php
while( have_rows('product_faq') ) : the_row();
// Load sub field value.
$product_question = get_sub_field('product_question');
$product_answer = get_sub_field('product_answer');
$id = rand();
?>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="<?php echo $id; ?>">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse<?php echo $id; ?>" aria-expanded="true" aria-controls="collapse<?php echo $id; ?>">
<i class="more-less glyphicon glyphicon-plus"></i>
<?php echo $product_question; ?>
</a>
</h4>
</div>
<div id="collapse<?php echo $id; ?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="<?php echo $id; ?>">
<div class="panel-body">
<?php echo $product_answer; ?>
</div>
</div>
</div>
<?php
// End loop.
endwhile;
?>
</div>
<?php
endif;
$output = ob_get_contents();
ob_end_clean();
return $output;
}
/*-------------- Shortcode :-3 ------------------*/
//Products Facts
function product_facts_func( $atts )
{
ob_start();
if( have_rows('product_facts') ):
while(have_rows('product_facts')):
the_row();
?>
<div class="col-sm-4 col-xs-12 text-center">
<div class="product-facts-box">
<div class="product-facts-image">
<img src="<?php the_sub_field('facts_icon');?>" />
</div>
<div class="product-facts-title">
<p><?php the_sub_field('facts_title'); ?></p>
</div>
<div class="product-facts-desc">
<p><?php the_sub_field('facts_text'); ?></p>
</div>
</div>
</div>
<?php
endwhile;
endif;
$output = ob_get_contents();
ob_end_clean();
return $output;
}
add_shortcode( 'product_facts', 'product_facts_func' );
//Products Facts
function product_facts_func( $atts )
{
ob_start();
if( have_rows('product_facts') ):
while(have_rows('product_facts')):
the_row();
?>
<div class="col-sm-4 col-xs-12 text-center">
<div class="product-facts-box">
<div class="product-facts-image">
<img src="<?php the_sub_field('facts_icon');?>" />
</div>
<div class="product-facts-title">
<p><?php the_sub_field('facts_title'); ?></p>
</div>
<div class="product-facts-desc">
<p><?php the_sub_field('facts_text'); ?></p>
</div>
</div>
</div>
<?php
endwhile;
endif;
$output = ob_get_contents();
ob_end_clean();
return $output;
}
add_shortcode( 'product_facts', 'product_facts_func' );