将链接添加到滑块横幅

Add links to slider banners

我的主页上有滑块横幅,但 link 没有到任何地方。我需要为每个图像添加什么代码 links?是否可以使用以下代码?:

Thank you! I need to add a different link to each banner. The banners are all going to the   printf('<a href="yourlink.html"> link. What am I doing wrong? <div id="home">
    <div class="banner">
        <div class="banner-slider">
            <?php
                if (!empty($options['slider_photo'])):
                    $slider_photos = explode(',', $options['slider_photo']);

                    foreach ($slider_photos as $k => $img):
                        printf('<a href="http://www.nemotile.com/tile/product/Handwritten/"><div class="banner-%d" style="background-image:url(%s)"></div></a>', $k, $img);
                    endforeach;
                else: ?>

                    <a href="http://www.nemotile.com/tile/product/Handwritten/"><div class="banner-1"></div></a>
                    <a href="http://www.nemotile.com/tile/product/patchwork/"><div class="banner-2"></div>
                    <a href="http://www.nemotile.com/tile/product/BisazzaCementTiles/"><div class="banner-3"></div>
                    <div class="banner-5"></div>
                <?php endif; ?>
        </div>

您可以将此代码更改为以下摘录。使用 $i 你可以通过你的 URL 数组,这应该给你它的一般过程。我不确定你是如何获得 URL 的,但这应该会让你走上正确的道路。

<div class="banner">
    <div class="banner-slider">
        <?php
        $urls = ['URL1', 'URL2', 'URL3', 'URL4'];
        $i = 0;

        if (!empty($options['slider_photo'])):
            $slider_photos = explode(',', $options['slider_photo']);

            foreach ($slider_photos as $k => $img):
                printf('<a href="'.$urls[$i].'"><div class="banner-%d" style="background-image:url(%s)"></div></a>', $k, $img);
                $i++;
            endforeach;
        else: ?>

        <a href="http://www.nemotile.com/tile/product/Handwritten/"><div class="banner-1"></div></a>
        <a href="http://www.nemotile.com/tile/product/patchwork/"><div class="banner-2"></div>
            <a href="http://www.nemotile.com/tile/product/BisazzaCementTiles/"><div class="banner-3"></div>
                <div class="banner-5"></div>
                <?php endif; ?>
    </div>