0

我目前正在为个人网站开发 Wordpress 主题,并决定使用 Slightly Modded Options Framework [SMOF] 来简化操作。到目前为止一切都很顺利,它确实是一个很棒的框架。今天我决定使用框架中的内置滑块选项并在我的主题上实现它,这就是我发现自己有点迷失的地方。

我设法使主题和框架显示幻灯片,但它不会旋转/圆形/滑动/淡化图像。它只显示第一张图像,它保持静止并且不会更改幻灯片。


这是我的代码,以防有人了解 SMOF:

这就是我的functions.php上的内容:

    $of_options[] = array(  "name"  => "Homepage Slideshow",
            "desc"  => "Slider Option Description",
            "id"    => "homepage_slider",
            "std"   => "",
            "type"  => "slider"
        );

这就是我的主题 index.php 中的内容:

    <?php $slides = $data['homepage_slider']; if ($slides) { ?>
    <!-- Start my Precio... uhum! I mean Slider -->
    <?php
        foreach ($slides as $slide) {

        }           
    ?>

    <?php if (!empty ($slide['link'])) { ?>
<a href="<?php echo $slide['link']; ?>" title="<?php echo htmlspecialchars(stripslashes($slide['title'])); ?>">
    <img src="<?php echo $slide['url']; ?>" width="950" height="369px" alt="<?php echo htmlspecialchars(stripslashes($slide['title'])); ?>" style="height: 369px; width: 100%;"/>
</a>

    <?php } else { ?>

<img src="<?php echo $slide['url']; ?>" width="950" height="369px" alt="<?php echo htmlspecialchars(stripslashes($slide['title'])); ?>" style="height: 369px; width: 100%;"/>                       
    <?php } ?>

    <?php if (count($slides) > 1) { ?>

    <!-- Die Slider! -->

    <?php
        } // End count
    ?>

    <?php
        } // End if
    ?>

可能问题出在循环上,但老实说,我尝试了很多方法,但无法让它交换图像。我将非常感谢任何帮助我解决这个问题的提示和指导。感谢大家!

4

1 回答 1

1

I am also using smof v 1.5 in a wordpress theme project. I've faced the same problem but after some research i've solved the issue. By using the following codes you can get the slider's each slide's values.

    <?php 
    global $smof_data;
    $slides = $smof_data['example_slider']; //get the slides array

    foreach ($slides as $slide) {
        echo $slide['title'];
        echo $slide['url'];
        echo $slide['link'];
        echo $slide['description'];
    }
    ?>

By using this code you can access each option element of smof and the key is "global $smof_data;" its not documented but i got if after reading ninezeroseven wordpress theme admin options files. Authors of ninezeroseven used this SMOF and i got the clue from the author coding. I've tried global variable $smof_data instead of $data and its works.

于 2013-12-05T18:20:40.533 回答