Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
[Solved] Get all options from a drop down field, not just the selected one?
-
Ok if anyone needs something like this, I did it this way:
$results = get_pages(array(
'numberposts' => -1,
'post_type' => 'acf',
'sort_column' => 'menu_order',
'order' => 'ASC',
));
//You'll need to find the corresponding key created by ACF and plug it into the first parameter. You should be able to find this with print_r($results);
$field = $acf->get_acf_field("field_4ff72cd781b1d", $results[0]->ID);
//get an array of all choices in a drop down.
print_r($field['choices']);
Hope this helps! -
For anyone stumbling upon this question you can use
get_field_object()to find the options in a select menu.$field_obj = get_field_object( 'field_506d7b9428874', $post_id_where_field_is );
If you take a look at the returned$field_objarray usingvar_dump( $field_obj )you will find the select menu options under 'choices'.
You should be able to access the options like this:foreach ( $field_obj['choices'] as option ){
echo option // Prints out the option
}