i'm using ACF and the repeater to spit out a series of subfields including: image header description button title button link
But, while most of the sliders have all of them, SOME don't have the button title or link so if i don't fill it out, it just shows the blank button with no text.
Can someone assist where in the code below i can hide the button if the user does not add in anything into the field in the meta field in the WP backend?
<?php if( have_rows('feature_slider') ): ?>
<div class="swiper-container">
<div class="swiper-wrapper">
<?php while( have_rows('feature_slider') ): the_row();
$feature_image = get_sub_field('feature_image');
$card_heading = get_sub_field('card_heading');
$card_description = get_sub_field('card_description');
$card_button_text = get_sub_field('card_button_text');
$card_link_url = get_sub_field('card_link_url');
?>
<!-- slider -->
<div class="swiper-slide">
<div class="bg--pattern"></div>
<div class="absolute c-card"><div class="card-content">
<h2><?php the_sub_field('card_heading'); ?></h2>
<p><?php the_sub_field('card_description'); ?></p>
<a class="card-btn" href="<?php the_sub_field('card_link_url'); ?>"><?php the_sub_field('card_button_text'); ?> ⟶</a></div></div>
<img src="<?php echo esc_url($feature_image['url']); ?>" alt="<?php echo esc_attr($feature_image['alt']); ?>" />
<div class="c--content-card">
<h2><?php the_sub_field('card_heading'); ?></h2>
<p><?php the_sub_field('card_description'); ?></p>
</div> <!-- card -->
</div> <!-- swiper slide -->
<?php endwhile; ?>
<?php endif; ?>
The button you'll see that i'm trying to hide is begins <a class="card-btn" .... but would also be useful to know how to do it for other ACF php I add in.
Thank you!