Home › Forums › Front-end Issues › link in a picture of a repeater
Hello,
n my repeater, I would like to include an image with a link going to the page that corresponds to the image. with the following code as soon as i add the link part, the images have disappeared.
Did I properly position my endif of <? Php if ($ link):?>
?
Thank you for your help
<?php if( have_rows('projets') ): ?>
<?php while( have_rows('projets') ): the_row();
$image = get_sub_field('image_projet');
$titleProject = get_sub_field('titre_du_projet');
$size = 'large'; // (thumbnail, medium, large, full or custom size)
$linkProject = get_sub_field('lien_vers_le_projet');
?>
<div class="col-xl-3 col-lg-3 col-md-6 col-sm-6 cas justify-content-center">
<?php if($link): ?>
<a href="<?php echo $linkProject; ?>" class="d-block w-100 a">
<?php if( $image ) {
echo wp_get_attachment_image( $image, '','',array(
"class" => "imageProjet"
) );
} ?>
</a>
<?php endif ?>
<div class="titreProjet" data-aos-duration="900" data-aos-once="true">
<?php echo $titleProject;?>
</div>
<div data-aos-delay="300" data-aos-duration="700" data-aos-easing="ease-in-out"
data-aos-once="true" class="trait">
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
I solved my problem
<?php if( have_rows('projets') ): ?>
<?php while( have_rows('projets') ): the_row();
$image = get_sub_field('image_projet');
$titleProject = get_sub_field('type_et_titre_du_projet');
?>
<div class="col-xl-3 col-lg-3 col-md-6 col-sm-6 cas justify-content-center">
<a class="d-block w-100 a" href="projet_cap_sciences.php#projets">
<img src="" alt="">
</a>
<div class="titreProjet" data-aos-duration="900" data-aos-once="true">
<?php echo $titleProject;?>
</div>
<div data-aos-delay="300" data-aos-duration="700" data-aos-easing="ease-in-out"
data-aos-once="true" class="trait">
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
$link
has no value, it is never set to anything in your code.
The topic ‘link in a picture of a repeater’ is closed to new replies.
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.