phpwordpresspluginsadvanced-custom-fieldsacfpro

ACF Link in Repeater doesn't work correctly


    <div class="section3">
    <?php if( have_rows('section3') ): ?>

    <?php while( have_rows('section3') ): the_row(); 

        // vars
        $image = get_sub_field('image');
        $title = get_sub_field('title');
        $caption = get_sub_field('caption');
        $link_text = get_sub_field('link_text');
        $link = get_sub_field('link');

        ?>
            <div class="container">
                    <div data-aos="fade-left">
                        <div class="section3-top">
                            <div class="rotatey">
                                <img src="<?php echo $image; ?>" alt="">
                            </div>
                            <div class="top__right">
                                <h6><?php echo $title; ?></h6>
                                <div class="desc">
                                    <?php echo $caption; ?>
                                </div>
                                <div class="click">

                                <?php if( $link ): ?>

                                    <a href="<?php $link; ?>" class="click__a">
                                        <img src="<?php bloginfo('template_directory');?>/assets/img/icons/right-arrow-grey.svg" alt=""
                                            class="click__right-arrow">
                                        <h6>View</h6>
                                    </a>
                                    <?php endif; ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

    <?php endwhile; ?>
<?php endif; ?>

All the Variables are working correctly except the link does the PHP inside the Html link tag not correct, the link is URL in the configuration. By the way, I'm new on PHP and Wordpress, Thanks.


Solution

  • You are missing a print/echo.

    <a href="<?php $link; ?>" class="click__a">
    

    Should be

    <a href="<?php echo $link; ?>" class="click__a">