WordPress.org

Support

Support » Plugins and Hacks » Simple Fields » [Resolved] [Plugin: Simple Fields] Problems with drop-down menu values

[Resolved] [Plugin: Simple Fields] Problems with drop-down menu values

  • I’m having a problem returning the value for drop-down menu values. I have a simple fields drop down in a page template within the WP dashboard, so I can choose a colour for an item via a dropdown on the page edit screen. If I use this:

    simple_fields_get_post_value(get_the_id(), array(4, 1), true);?>

    then the value returned is ‘green’ – the value I have chosen in the simple field dropdown within the WP dashboard.

    However, I want to do this using the ‘slug’ instead of the ‘meta-key’:

    <?php $breadcrumbcolor = simple_fields_value('breadcrumb_colour');?>

    but the value returned is ‘dropdown_num_2’.

    I can see how I can use ‘dropdown_num_2’ as a class in the css but it’s going to be much more labour intensive AND if I change anything in the simple fields setup – the order of the values etc, it will mess up the css as the ‘dropdown_num’ changes.

    Is there anyway to return the actual value using the slug method?

    http://wordpress.org/extend/plugins/simple-fields/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Pär Thernström

    @eskapism

    Ah, yes that return value is a bit strange for some.

    Hold on a day or day and a new version of simple fields will be out and that version will have a very good solution to your problem – promise!

    Plugin Author Pär Thernström

    @eskapism

    Hi again! With the latest version of simple fields you can now do this:

    $breadcrumbcolor = simple_fields_value('breadcrumb_colour', NULL, "extended_return=1");?>
    
    echo "The selected color is: " . $breadcrumbcolor["selected_value"];

    Try it and let me know if it works.

    Wow, how rude of me – I never got back to say that this worked for me. Apologies and thanks!

    Hi Thernström,
    I’m trying to do the same but with a dropdown which has multiple values selectable.
    And this code doesn’t return anything. I think I tried every possible combinations 😉
    Thanks for your help !

    Got it !

    $intervenants = simple_fields_value('intervenants');
      $intervenant = $intervenants['selected_values'];
      foreach($intervenant as $name) {
        echo $name;
      };

    I didn’t expect to use a foreach…

    Plugin Author Pär Thernström

    @eskapism

    Nice to hear that you solved it. Also very kind of you to share you solution with the other users of this support forum. Thanks!

    The secret of a long life resides in the share 😉
    I always proceed like that.
    But, sometimes, I got real questions hard to solve by myself… check the other recent topics !
    Again, thanks a lot for your work on this plugin !

    Hello!

    I love this plugin!
    I need to read what the selectable values for a specific drop down field so that I may create a drop down menu on the front end for the user.

    Example, I have a list of industries that the user selects when creating their posts. I’d like to create a drop down menu on a specific page that is the same as the drop down in the simple fields – I am doing this in PHP and it’s for the site visitor to be able to select by a specific industry. This page needs to build this drop down dynamically incase the client decides to add/change the industries available in simple fields.

    Hope this makes sense.
    thanks,
    rich

    Also,

    What happened to the required fields checkbox? I don’t see it in this latest version of Simple Fields.

    THanks,
    rich

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] [Plugin: Simple Fields] Problems with drop-down menu values’ is closed to new replies.
Skip to toolbar