Home › Forums › Add-ons › Repeater Field › how would you create multiple galleries with ACF? › Reply To: how would you create multiple galleries with ACF?
function mbgc_gallery_shortcode( $atts ) {
// $post_id = $atts['id'];
extract( shortcode_atts(
array(
'id' => '',
), $atts )
);
$html_out = '123';
// $post = get_post( $id );
// if ( $post ) :
if( have_rows('mbgc_gallery') ):
$html_out .= '<div class="mbgc-gallery owl-carousel owl-theme">';
while( have_rows('mbgc_gallery') ): the_row();
// vars
$image = get_sub_field('mbgc_image');
$caption = get_sub_field('mbgc_caption');
$title = get_sub_field('mbgc_title');
$sub_title = get_sub_field('mbgc_sub_title');
var_dump($caption);
if ( $image ) :
$html_out .= '<div class="mbgc-gallery-item">';
if ( $caption ) :
$html_out .= '<div class="mbgc-slide-caption">';
$html_out .= '<h4>' . $caption . '</h4>';
$html_out .= '<div class="mbgc-slide-titles">';
$html_out .= '<h6>' . $title . '</h6>';
$html_out .= '<h6>' . $sub_title . '</h6>';
$html_out .= '</div>';
$html_out .= '</div>';
endif;
$html_out .= '<div class="mbgc-slide">';
$html_out .= '<img src="' . $image['url'] . '" alt="' . $image['alt'] . '" />';
$html_out .= '</div>';
$html_out .= '</div>';
endif;
endwhile;
$html_out .= '</div>';
endif;
// endif;
return $html_out;
}
add_shortcode('mbgc_gallery', 'mbgc_gallery_shortcode');
This is probably out of the scope of what you can help with, but I am trying to write a function based on what you said. Creating a Custom Post Type. I can’t get this to work though. I tried [mbgc_gallery id=”401″] and it outputs nothing, only the test 123
. I tried a var_dump
and nothing neither. Am I using the repeater code correctly?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.