Simple Fields
[resolved] WP_Query and dropdowns (4 posts)

  1. kingzjester
    Posted 3 years ago #

    I have a WP_Query that filters by a field that was defined through a dropdown—but the meta value for it is actually 'dropdown_num_9' or whatever, not the actual dropdown value, so this meta_query fails to find anything:

    'meta_query' => array(array(
      'key'     => '_simple_fields_fieldGroupID_3_fieldID_6_numInSet_0',
      'compare' => '=',
      'value'   => $category

    What is the best way to ask the simple-fields for all the dropdown values and keys ahead of time so that I can bake the WP_Query to look for the pre-baked key values and bypass this grief?


  2. Pär Thernström
    Plugin Author

    Posted 3 years ago #

    This code would work as a start I think:

    global $sf;
    $field = $sf->get_field_by_slug($field_slug = "", $fieldgroup_slug = "");

    Then check how the $field-array is constructed and you can figure out how to get the value for the dropdown.

  3. niemion
    Posted 3 years ago #

    Is seems wild that there is no simple way to ask for the actual dropdown value. The lack of ability to get to the dropdown and radio values was questioned years back, and people started hammering in the code itself to get it working.

    It seems irrational.

  4. Pär Thernström
    Plugin Author

    Posted 3 years ago #

    You can add this as a feature request over at github:

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Simple Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.