Tagged: 

Viewing 2 reply threads
  • Author
    Posts
    • #4229
      vagelis
      Member

      I have this select field with two options:

      piklist('field', array(
       'type' => 'select'
       ,'field' => 'yachts_fuel'
       ,'label' => 'Καύσιμο'
       ,'value' => 'option1'
       ,'attributes' => array(
         'class' => 'text'
       )
       ,'choices' => array(
        'option1' => 'Πετρέλαιο'
        ,'option2' => 'Βενζίνη'
        )
       ));

      I want to show in the front end the value of ‘option1’ which is ‘Πετρέλαιο’. Using get_post_meta is returning the ‘option1’ and not the text ‘Πετρέλαιο’ that I want. How can I get that?

      get_post_meta($post->ID, 'yachts_fuel', true ); is what I used.

    • #4230
      Steve
      Keymaster

      Frontend rendering for this type of field isn’t implemented yet. You need to go old school. Try this:

      $yachts_fuel = get_post_meta($post->ID, 'yachts_fuel', true )
      
      switch ($yachts_fuel)
      {
        case 'option1':
            echo 'Πετρέλαιο';
            break;
        case 'option2':
            echo 'Βενζίνη';
            break;
      }
      
    • #4231
      vagelis
      Member

      Strike! Just perfect Steve. Thanx.

Viewing 2 reply threads
  • The topic ‘Get name of option from select field’ is closed to new replies.