WordPress.org

Ready to get started?Download WordPress

Forums

Simple Fields
[resolved] Problems with drop-down menu values (10 posts)

  1. cokeyblokey
    Member
    Posted 1 year ago #

    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/

  2. Pär Thernström
    Member
    Plugin Author

    Posted 1 year ago #

    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!

  3. Pär Thernström
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  4. cokeyblokey
    Member
    Posted 1 year ago #

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

  5. sugardaddy
    Member
    Posted 1 year ago #

    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 !

  6. sugardaddy
    Member
    Posted 1 year ago #

    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...

  7. Pär Thernström
    Member
    Plugin Author

    Posted 1 year ago #

    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!

  8. sugardaddy
    Member
    Posted 1 year ago #

    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 !

  9. Rabassa
    Member
    Posted 1 year ago #

    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

  10. Rabassa
    Member
    Posted 1 year ago #

    Also,

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

    THanks,
    rich

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic