I’ve created a Field group called ‘Team Members’ and set the field type as repeatable with three sub fields; Image, Position and Name.
The rule for this group is to show within a custom widget I’ve created. When I drag the widget in the Appearance > Widgets area of WordPress I can see it is indeed there and can add members / images to my widget.
Where I’ve hit a brick wall is trying to output this data on the front end through my widget template.
This is my code:
<?php if( have_rows(‘team_members’) ): ?>
<ul class=”slides”>
<?php while( have_rows(‘team_members’) ): the_row();
// vars
$image = get_sub_field(‘image’);
$content = get_sub_field(‘name’);
$link = get_sub_field(‘position’);
?>
<li class=”slide”>
<?php if( $link ): ?>
“>
<?php endif; ?>
” alt=”<?php echo $image[‘alt’] ?>” />
<?php if( $link ): ?>
<?php endif; ?>
<?php echo $content; ?>
<?php endwhile; ?>
<?php endif; ?>
Where am I going wrong?
Can’t really read you code. You should use the code tag at the top of the editor when posting code.
Have you read this document on getting values from a widget?
http://www.advancedcustomfields.com/resources/get-values-widget/