Title: Slider Loop Array
Last modified: August 20, 2016

---

# Slider Loop Array

 *  Resolved [sam.skirrow](https://wordpress.org/support/users/samskirrow/)
 * (@samskirrow)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/slider-loop-array/)
 * Hi,
    I know this is in the documentation, but can anyone talk me through in a
   bit ore detail how to create a slider loop array?
 * What I’m struggling with is to understand what Sections and Settings to add and
   what ID etc do I need to give these?
 * I currently have this code:
 *     ```
       </div>
           <div id="my-carousel">
           <ul>
       <?php
       if ( function_exists( 'ot_get_option' ) ) {
   
         /* get the slider array */
         $slides = ot_get_option( 'my_slider', array() );
   
         if ( ! empty( $slides ) ) {
           foreach( $slides as $slide ) {
             echo '
             <li>
               <img src="' . $slide['image'] . '" /></a>
   
             </li>';
           }
         }
   
       }
       ?>
           </ul>
       </div>
       ```
   
 * and I have a section called Slider with an ID of home_slider, in that section
   is a list-item Setting with the label Slider and ID of my_slider
 * Thanks in advance,
    Sam
 * [http://wordpress.org/extend/plugins/option-tree/](http://wordpress.org/extend/plugins/option-tree/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Derek Herman](https://wordpress.org/support/users/valendesigns/)
 * (@valendesigns)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/slider-loop-array/#post-3136414)
 * Than this code should already work for you as the option you’re trying to get
   data for is actually `my_slider`.
 * This part get’s the array of slides.
 * `$slides = ot_get_option( 'my_slider', array() );`
 * The part below checks that the array is not empty and loops over it to echo out
   a unordered list of images. Depending on what settings are in your list item 
   the array keys may not be the same. You’ll need to do a `print_r($slides);` to
   find out what your array keys are. For example, the `$slide['image']` above is
   asking for the value of an item in the array that has a key of “image”.

Viewing 1 replies (of 1 total)

The topic ‘Slider Loop Array’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/option-tree_363534.svg)
 * [OptionTree](https://wordpress.org/plugins/option-tree/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/option-tree/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/option-tree/)
 * [Active Topics](https://wordpress.org/support/plugin/option-tree/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/option-tree/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/option-tree/reviews/)

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)

 * 1 reply
 * 2 participants
 * Last reply from: [Derek Herman](https://wordpress.org/support/users/valendesigns/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/slider-loop-array/#post-3136414)
 * Status: resolved