How to get wordpress option tree list item data

i use option tree list item for getting social icon & links.but i cannot get data from backend.

array(
    'id'          => 'social_icon',
    'label'       => __( 'Footer Social Icons & links', 'theme-text-domain' ),
    'desc'        => __( '', 'theme-text-domain' ),
    'std'         => '',
    'type'        => 'list-item',
    'section'     => 'header_footer',
    'rows'        => '',
    'post_type'   => '',
    'taxonomy'    => '',
    'min_max_step'=> '',
    'class'       => '',
    'condition'   => '',
    'operator'    => 'and',
    'settings'    => array( 
      array(
        'id'          => 'social_icon_fb',
        'label'       => __( 'link', 'theme-text-domain' ),
        'desc'        => '',
        'std'         => '',
        'type'        => 'text',
        'rows'        => '10',
        'post_type'   => '',
        'taxonomy'    => '',
        'min_max_step'=> '',
        'class'       => '',
        'condition'   => '',
        'operator'    => 'and'
      ),
      array(
        'id'          => 'social_icon_upl',
        'label'       => __( 'icon', 'theme-text-domain' ),
        'desc'        => 'the best sixe for icon is 31x31.',
        'std'         => '',
        'type'        => 'upload',
        'rows'        => '10',
        'post_type'   => '',
        'taxonomy'    => '',
        'min_max_step'=> '',
        'class'       => '',
        'condition'   => '',
        'operator'    => 'and'
      ),
    )
  )

and i want to use this in

Read More
<ul id="icons">
    <li>
        <a href="<?php get_option_tree( 'social_icon_fb', '', 'true' ); ?>" class="normaltip" title="Facebook"><img src="<?php get_option_tree( 'social_icon_upl', '', 'true' ); ?>" alt=""></a>
    </li>
</ul>

i use this to get data from backend.is this correct?? if no so what should be the code to get data.

Related posts

Leave a Reply

2 comments

  1. Try this code

       <?php 
    if ( function_exists( 'ot_get_option' ) ) {
    
      /* get the slider array */
      $slides = ot_get_option( 'social_icon', array() );
      if ( ! empty( $slides ) ) {
        foreach( $slides as $slide ) {
          echo '
    
    <li>
        <a href="'.$slide['social_icon_fb'].'" class="normaltip" title="Facebook"><img src="'.$slide['social_icon_upl'].'" alt=""></a>
    </li>
    
          ';
        }
      }
    
     }
    ?>
    
  2. list item always return array. you have to use foreach loop for getting every row of array. code is describe bellow.

    *<?php 
        if ( function_exists( 'ot_get_option' ) ) {
            $your_listitems_array = ot_get_option( 'your_listitems_slug', array() );
            if ( ! empty( $your_listitems_array ) ) {
                foreach( $your_listitems_array as $your_listitem) {
                    echo $your_listitem['your_listitem_option_slug'];
                }
            }
        }
    ?>*