wordpress - Get select box values of advanced custom field -
I am using a field type criminal field type. The original field name is 'map_details' and the sub field name is 'Name_of_county' which is a select dropdown list.
Now I want to display all the values of that selection box in front. My code is
$ field_key = "field_535befe551ba5"; // field key of the original field = get_field_object ($ field_key); If ($ field) {echo '& lt; Select name = ''. $ Field ['key']. "& Gt; '; Foreign currency ($ field [' option '] $ k => $ v) {echo' 'lt; option value =' ' $ K. "& Gt; '$ V.' & lt; / option & gt; ';} echo'
';}
This work Not because I did not give parent field field field, which is basically a selection box, except that I can not find the field key for the sub region.
I have a front field How can I show sub-field dropdown boxes with values and keys in
Recently I have a value in frontend Find a way to output keys / keys: In these cases, I always print to understand parent array (between 'pre-tags'), trust me ... it helps a repeater As a result, one step deeper in the selection field (sub-field) array, so:
$ field_key = "field_535befe551ba5"; // field key of the original field = get_field_object ($ field_key) ; If ($ field) {/ as explained, then look at the structure of the // array already. To print throat 3 lines / print it in a beautiful way, // resonate '& lt; Pre & gt; '; // print_r ($ field); // resonance '& lt; / Pre & gt; '; Foreign currency ($ field ['sub-field'] $ the_subfield) {$ the_subfield_name = $ the_subfield ['name']; // If you have more than one subfield in the repeater, then // we have to check that we are in the desired subfield: if ($ the_subfield_name == 'name_of_the_subfield') {// In your case: 'name_of_country' // Now we are sure that we are within the desired // subfield, we will output various options available. Forex Currency ($ the_subfield ['option'] $ k => $ v) {echo '& lt; Option value = "'. $ K." & Gt; '. $ V '& Lt; / Option & gt; '; } Echo '& lt; / Select & gt; '; }}}
I hope it helps!
Comments
Post a Comment