WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. kingzjester
    Member
    Posted 1 year 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?

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

  2. Pär Thernström
    Member
    Plugin Author

    Posted 1 year ago #

    This code would work as a start I think:

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

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

  3. niemion
    Member
    Posted 1 year 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
    Member
    Plugin Author

    Posted 1 year ago #

    You can add this as a feature request over at github:
    https://github.com/bonny/WordPress-Simple-Fields

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.