Follow us on

Codestar Support Forum » WordPress Plugins » Codestar Framework

how to display select fields array data

  1. array(
          'id'          => 'header-select',
          'type'        => 'select',
          'title'       => 'Select',
          'chosen'      => true,
          'placeholder' => 'Select an option',
          'options'     => array(
            'header-1'  => 'Header Style 1',
            'header-2'  => 'Header Style 2',
          ),
          'default'     => 'header-1'
        ),CopyCopied!

    <div class="div">
    	<?php
    	$option1 = stok_header('header-select');
    
    	if($option1['header-1'] ) {
    	get_template_part('inc/header/header-style1');
    } 
    
    	if($option1['header-2'] ) {
         get_template_part('inc/header/header-style2');   
    
    }   ?>
    
    	</div>CopyCopied!

    Please give an example , my code not working, also make sure if no header style selected then work my default header

    Posted 2 years ago #

  2. Codestar
    Admin

    Hi,

    Sorry for delay, I am back.

    Try this:

    <div class="div">
      <?php
    
        $option1 = stok_header('header-select');
    
        if ( $option1 === 'header-1' ) {
          get_template_part('inc/header/header-style1');
        } 
    
        if ( $option1 === 'header-2' ) {
          get_template_part('inc/header/header-style2');
        } 
    
      ?>
    </div>CopyCopied!

    Regards, Codestar

    Posted 2 years ago #