The get_field_object
ACF function can be used to get info and options for a specific field.
First you need the field key of the specific field you wish to output. When editing a field group, click on the screen options tab at the top of the page. You should see an option to toggle the display of the field key (it is hidden by default to save space):
Once you have the key, you can load the field object and output its values:
$field_key = "field_5039a99716d1d";
$field = get_field_object($field_key);
if( $field )
{
echo '<select name="' . $field['key'] . '">';
foreach( $field['choices'] as $k => $v )
{
echo '<option value="' . $k . '">' . $v . '</option>';
}
echo '</select>';
}
Related Posts:
- If Custom Field is empty don’t display div
- Unique key for each row in a repeater field
- How to Explode a Textarea Field and Echo each line separately, wrapped with HTML
- Importing hard coded custom field into acf field
- Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
- How to use thumbnail size of image if I’m only using src to get image
- Advanced Custom Fields – display label and value only if value entered
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- Creating an image from a custom field
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Including Custom fields within the_content
- Delete images from media library when user deletes an image from ACF Gallery
- Query on a repeater date (acf)
- ACF – Can’t get custom post type by taxonomy
- ACF Date fileds to Age Convert [closed]
- ACF number less than comparison not working
- Cannot Access ACF Field Values via my Plugin
- How to create advanced custom fields for backend content
- Display posts in correct month order using single date custom field
- Seach custom post type posts only by meta fields?
- Slick + PHP + ACF + JQuery slide reveal not working
- 3 Slashes appear after Apostrophe in custom fields after updating product-site
- how to retrieve a value if a checkbox is checked
- Trouble checking if custom woocommerce checkout field is empty or not
- Two queries for a WP_User_Query search work perfectly apart, but not together
- auto-populating custom nav with all items from custom post type
- Add / Update Custom Fields After Select Pictures in Media Window
- conditional logic for front-end custom field edits
- Trying to retrieve post meta
- Displaying custom field according to date
- Sort by page information by Ascending Numbers
- Automatic Shortcode Creation with Custom Fields [closed]
- Custom field values to taxonomy terms
- How would an if statement surrounding a custom field with two variables (holding values) look like?
- Redirect to another page using contact form 7? [closed]
- How to add specific meta tags to head of cart and checkout pages in woocommerce?
- Custom Field IF/ELSE PHP
- Which PHP page is the Default Posts Page
- How to combine 2 php functions into one function with a custom field
- Remove the last X characters of a custom field value
- Is it possible to retrieve all posts with a certain value for metadata?
- Advanced Custom Fields not displaying
- Saving zero in meta box
- Non-Closing PHP Query in WordPress Loop
- Find a way to retrive data updated through metabox plugin to web page
- Download PDF after CF7 form submission
- Why are the details of my todo not saving?
- How to check if a PHP string is different than meta field?
- Can’t save php string to a custom field
- Display custom field on 404 page outside loop
- Why does this update_post_meta function not delete the custom field itself?
- How to create an ACF shortcode with Repeater Field in WordPress? [duplicate]
- How to show/hide php table rows based on the content of custom fields
- Run str_replace on title and save the output to a custom field
- Only show image from custom field when present
- Upload non-featured image to image field
- how to get serialized post meta
- Hide Heading if ACF Field is empty
- Custom meta box values are not getting saved for my custom post type
- HTML Special Characters in URL string [closed]
- ACF put a comma after the last repeater field value [closed]
- WP_Query: getting posts where custom field exists
- How to show meta value code HTML after x paragraph
- Form search query – displaying ACF “Post Object” field as results
- InnerBlocks with allowedBlocks not working with acf_register_block
- Accessing values from ACF sub field (flexible content area) in PHP
- Can I set up a hover animation in CSS depending on a PHP conditional?
- Get ACF options field in PHP acting as CSS
- User Meta Value not echoing despite Var_Dump Showing correct string
- WordPress loop by meta key that is an array? and how loop multiple arrays
- ACF & Bootstrap Gallery Shows Blank Slides [closed]
- Conditional multidimensional arrays and array_map
- ACF Repeater Pagination stopped working since upgrade to php7.2
- How can I count ACF sub_field with a certain value
- if custom field doesn’t exist, use post thumbnail instead, as image background
- WP All Import / Update stock quantity from multiple XML files
- How to store multiple custom meta box
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- what is the method to echo class attribute inside the i tag? [closed]
- Refactoring long if/else php chains
- Getting taxonomy category Image from ACF [closed]
- Handling repeater data
- How to add data to a custom field at the wp_users table?
- Concatenate Custom Field Value & HTML Value
- Show get_sub_field value if it exists [closed]
- Update post meta – Custom field does not match meta-key
- Output custom text field as unordered list
- Conditional featured image with youtube thumbnail
- Advanced Custom Fields [closed]
- `update_post_meta` not working anymore
- Order a WP_Query by meta value where the value is an array
- Unable to render custom field after attempt to generate a list of recent post in page template
- Add a custom class to the body tag using custom fields
- Define category ID using get_post_meta
- Add a counter for mouseovers (custom field)
- ACF Unexpected T_CONSTANT_ENCAPSED_STRING [closed]
- Hide a div when a custom field is empty
- How can i make a search box to search by custom field
- Get All In One SEO Pack to use custom field instead of Content
- Remove Post if Advanced Custom Field is checked to fix paging