Home › Forums › Add-ons › Repeater Field › Select field in repeater to print css classes
For some reason I’m having a hard time just echoing a value while inside of a repeater using a select field. I have a select menu field called ‘gallery_content_orientation’ => Here’s the code I have:
<?php if( have_rows('homepage_slideshow') ): ?> <div class="single-slide"> <?php while( have_rows('homepage_slideshow') ): the_row(); // vars $gallery_image = get_sub_field('homegallery_image'); $gallery_link = get_sub_field('homegallery_image_link'); $gallery_title = get_sub_field('homegallery_image_title'); $gallery_content = get_sub_field('homegallery_content_area'); $gallery_classes = get_sub_field('gallery_content_orientation'); ?> <div class="slide-inner-content" style="background-image: url(<?php if( $gallery_image ): ?><?php echo $gallery_image['sizes']['slideshow_hero']; ?><?php endif; ?>)";> <?php if( $gallery_link ): ?><a href="<?php echo $gallery_link; ?>" class="hero-link"></a><?php endif; ?> <div class="row slide-content <?php echo $gallery_classes?>"> <div class="slide-panel"><?php if($gallery_title): ?><h1 class="font-effect-shadow"><?php echo $gallery_title; ?></h1><?php endif; ?> <?php if($gallery_content): ?><?php echo $gallery_content; ?><?php endif; ?></div> </div> </div> <?php endwhile; ?> </div> <?php endif; ?>
So the $gallery_classes above would print the orientation class (like top center, left, etc.) – I have this on each slide so the user can choose the orientation. But I can’t get it to output. I’ve read the docs but I usually get a white screen!
Hope someone out there can help, thank you!
Gallery classes is a select field that allows multiple choices?
Its a select field that would only allow one choice. So, for example, a few choices might be: top, left, right, etc. But I’d only allow one to be selected to add the class.
Thanks for looking!
okay, so I don’t see what would be causing an error that would give you a white screen, the first thing we’ll need to do is figure that out.
Edit wp-config.php and add the following, or adjust what’s already there.
define('WP_DEBUG', true ); define('WP_DEBUG_DISPLAY', true); define('WP_DEBUG_LOG', false);
Then when you load the page we should at least be able to see what the error is that’s crashing the page.
OK so the problem turned out to be something with my PHP code later on after this code block – I didn’t properly close a PHP statement. Thanks for the debug options!
Everything works now – thanks a ton!
You must be logged in to reply to this topic.
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!
Are you building WordPress sites with ACF and @BeaverBuilder, and wanted to use your ACF Blocks in both the block editor and Beaver Builder?— Advanced Custom Fields (@wp_acf) May 10, 2023
The BB team recently added support for using ACF Blocks in Beaver Builder. Check it out 👇https://t.co/UalEIa5aQi
© 2023 Advanced Custom Fields.