-
AuthorPosts
-
June 2, 2014 at 11:15 am #273166
Hi there,
I’m using advanced custom fields with the theme. This plugin what it does is to provide a nice UI and add custom fields to any kind of post. One of this fields is call repeater field, and stores the data for multiples fields on an array of sub-fields.
http://www.advancedcustomfields.com/resources/field-types/repeater/
What I want is to use those fields that I have from before changing the theme, to keep all the info.
The common code to display does fiels is this
$rows = get_field('repeater_field_name'); if($rows) { echo '<ul>'; foreach($rows as $row) { echo '<li>sub_field_1 = ' . $row['sub_field_1'] . ', sub_field_2 = ' . $row['sub_field_2'] .', etc</li>'; } echo '</ul>'; }
The thing is I’m trying to use [av_section] and [av_slideshow] in php using do_shortcode, and this is the code that I create:
echo do_shortcode("[av_section color='main_color' custom_bg='' src='' attach='scroll' position='top left' repeat='no-repeat' video='' video_ratio='16:9' video_mobile_disabled='' min_height='' padding='default' shadow='no-shadow' id='']"); echo do_shortcode ("[av_slideshow size='featured' animation='fade' autoplay='true' interval='5']"); $rows = get_field('images'); foreach($row as $row) : echo do_shortcode("[av_slide slide_type='image' id='" . $row['image'] ."' attachment=',' video='http://' mobile_image='' video_ratio='16:9' title='' link_apply='image' link='lightbox' link_target='']"); echo $row['image']; echo do_shortcode("[/av_slide]"); endforeach; echo do_shortcode("[/av_slideshow]"); echo do_shortcode("[/av_section]");
But this doesn’t works at all. How should I do it? Thanks.
June 2, 2014 at 11:28 am #273177Hey Pedro!
You can’t wrap a shortcode this way. Your only chance would be to use $row[‘image’] as part of the av_slide shortcode like:
$rows = get_field('images'); $output = " [av_section color='main_color' custom_bg='' src='' attach='scroll' position='top left' repeat='no-repeat' video='' video_ratio='16:9' video_mobile_disabled='' min_height='' padding='default' shadow='no-shadow' id=''] "; $output .= "[av_slideshow size='featured' animation='slide' autoplay='false' interval='5' custom_class='']"; foreach($row as $row){ $output .= " [av_slide id='{$row['image']}'] "; } $output .= '[/av_slideshow] [/av_section] '; echo do_shortcode($output);
and $row[‘image’] MUST contain a valid image/attachment id.
Cheers!
PeterJune 2, 2014 at 1:15 pm #273226Thank you so much!! :D
-
AuthorPosts
- The topic ‘Advanced Custom Fields and enfold’ is closed to new replies.