0
votes

I am trying to grab the slider data from my custom theme options panel by using the code below. This is returning the following error

Warning: Invalid argument supplied for foreach() in /home/muratgok/public_html/wp-content/themes/default/page - clients.php on line 16

I am guessing that my syntax is not entirely correct but I am struggling to see where. Thank you

        <?php echo $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'];
        }

        ?>

Theme options code below

$of_options[] = array(  "name"      => "Slider Options",
                        "desc"      => "Unlimited slider with drag and drop sortings.",
                        "id"        => "example_slider",
                        "std"       => "",
                        "type"      => "slider"
                );
1

1 Answers

1
votes

Try with and be sure that is an array $smof_data['example_slider']:

    <?php $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'];
    }

    ?>