WordPress.org

Ready to get started?Download WordPress

Forums

OptionTree
[resolved] How to reference list items? (8 posts)

  1. nlsubtitles
    Member
    Posted 2 years ago #

    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!!

    http://wordpress.org/extend/plugins/option-tree/

  2. nlsubtitles
    Member
    Posted 2 years ago #

    found the solution myself:)

  3. Danilux
    Member
    Posted 2 years ago #

    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.

  4. Derek Herman
    Member
    Plugin Author

    Posted 2 years ago #

    @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.

  5. nlsubtitles
    Member
    Posted 2 years ago #

    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..

  6. vabmedia
    Member
    Posted 1 year ago #

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

  7. Derek Herman
    Member
    Plugin Author

    Posted 1 year ago #

    @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'] . '" />';
        }
      }
    
    }
  8. vexdex
    Member
    Posted 1 year ago #

    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 ?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.