• Resolved nlsubtitles

    (@nlsubtitles)


    Hi,

    There is probably a pretty simple answer to this question but I can’t seem to find it anywhere.

    When list items are created, how do you echo those in the theme?
    Every list item setting has an ID, but when multiple items are added to the list, what is the ID of the second one, third one and so on..?

    And is there a way to put a maximum to a list? So that no more than 3 items can be added.

    Thanks!!

    https://www.ads-software.com/extend/plugins/option-tree/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter nlsubtitles

    (@nlsubtitles)

    found the solution myself:)

    I need a way to reference list items, can’t seem to be able to get the values. For slider is pretty simple like $proyect_images[‘image’]; but can’t get to the correct array when using list items.

    Plugin Author Derek Herman

    (@valendesigns)

    @danilux You need to do a print_r() on the list item array and see what the keys are so you can echo things out properly.

    Thread Starter nlsubtitles

    (@nlsubtitles)

    Yes I did it the same way.
    It should be something like

    echo slider[0][the_id]
    echo slider[1][the_id]

    and so on..

    How did you output your images? I’m having trouble outputting images from a list item meta box.

    Plugin Author Derek Herman

    (@valendesigns)

    @vabmedia print_r() the array and take note of your array keys. Once you know what the keys are you would do a foreach loop and echo the HTML you need to display your images.

    The following code would echo the images if the key was “src” and the setting ID was “images”

    if ( function_exists( 'ot_get_option' ) ) {
    
      /* get the images array */
      $images = ot_get_option( 'images', array() );
    
      if ( ! empty( $images ) ) {
        foreach( $images as $image ) {
          echo '<img src="' . $image['src'] . '" alt="' . $image['title'] . '" />';
        }
      }
    
    }

    Hi, Derek. Thanks for your beautiful plugin. But, I have problem with insert next level list-item in list-item. I need to include list slides in list sliders. Does it possible with your plugin ?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: OptionTree] How to reference list items?’ is closed to new replies.