Support

Account

Home Forums Front-end Issues link in a picture of a repeater

Solving

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.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘link in a picture of a repeater’ is closed to new replies.