Follow us on

Codestar Support Forum » WordPress Plugins » Codestar Framework

Unable to getting correct value with repeater field

  1. what is ta correct code for getting the repeater value in the front end for this?

    <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
    // Control core classes for avoid errors
    if( class_exists( 'CSF' ) ) {

    //
    // Set a unique slug-like ID
    $prefix = '_akbuilder_options';

    //
    // Create options
    //
    CSF::createOptions( $prefix, array(
    'menu_title' => 'Setting Pannel',
    'menu_slug' => 'akbuilder-setting',
    ) );

    //
    // Create a section
    CSF::createSection( $prefix, array(
    'title' => 'Testimonials',
    'icon' => 'fa fa-comment',
    'fields' => array(
    array(
    'id' => 'tstmnl-small-title',
    'type' => 'text',
    'title' => 'Small Title',
    'default'=> 'OUR TESTIMONIALS ',
    ),

    array(
    'id' => 'tstmnl-big-title',
    'type' => 'text',
    'title' => 'Big Title',
    'default' => 'Our Sweet Client Say',
    ),

    array(
    'id' => 'tstmnl',
    'type' => 'repeater',
    'fields' => array(
    array(
    'id' => 'people-say',
    'type' => 'textarea',
    'title' => 'People Said',
    'placeholder' => 'Type what they said about your work ...'
    ),

    array(
    'id' => 'people-say-img',
    'type' => 'upload',
    'title' => 'Image',
    'placeholder' => 'http://',
    'library' => 'image',
    ),

    array(
    'id' => 'say-name',
    'type' => 'text',
    'title' => 'Text',
    'placeholder' => 'Kobid Kunwar',
    ),

    array(
    'id' => 'say-position',
    'type' => 'text',
    'title' => 'Position',
    'placeholder' => 'MD, CEO, Diretor',
    ),
    ),
    ),
    )
    )
    );
    }
    when I use like that I saw 1 numeric value on before actual data
    <?php echo ( ! empty( $tstmnl['people-say'] ) ), ( $tstmnl['people-say']); ?>

    Posted 1 year ago #
  2. http://codestarframework.com/documentation/#/
    Scroll down to "How to get option value?"

    Posted 1 year ago #
  3. kpirnie i am asking a about Repeater field not a regular field

    Posted 1 year ago #

  4. Codestar
    Admin

    Hi @basudevkunwar,

    You can manage it like this:

    $options = get_option( '_akbuilder_options' );
    
    if ( ! empty( $options['tstmnl'] ) ) {
    
      // It must be a foreach, because it is a multidimensional array output.
      foreach ( $options['tstmnl'] as $item ) {
    
        echo ( ! empty( $item['people-say'] ) ) ? $item['people-say'] : '';
        echo ( ! empty( $item['people-say-img'] ) ) ? $item['people-say-img'] : '';
        echo ( ! empty( $item['say-name'] ) ) ? $item['say-name'] : '';
        echo ( ! empty( $item['say-position'] ) ) ? $item['say-position'] : '';
    
      }
    
    }CopyCopied!
    Posted 1 year ago #
  5. Thank you

    Posted 1 year ago #

  6. Codestar
    Admin

    You're welcome

    Posted 1 year ago #