WordPress.org

Support

Support » Plugins and Hacks » OptionTree » [Resolved] Slider Loop Array

[Resolved] 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/

Viewing 1 replies (of 1 total)
  • Plugin Author Derek Herman

    @valendesigns

    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 ‘[Resolved] Slider Loop Array’ is closed to new replies.
Skip to toolbar