The $field
variable isn’t available inside your get_callback()
function. PHP isn’t like JavaScript in that way, and that function can’t access variables from outside its scope (unless it’s global
, but that’s a poor solution).
To pass the $field
variable through to the callback function, you need to write it like this:
'get_callback' => function() use ( $field ) {
return get_field( $field );
}
Related Posts:
- How do I set the default admin sort order for a custom post type to a custom column?
- How can I change the admin search posts fields?
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- WordPress 4.4+ : How to revision CPT + metadata
- Query custom post type by custom field
- Adding meta values to permalink
- Filter a custom field based on selection of another custom field (ACF) [closed]
- How to get custom metabox image field?
- Using custom field as custom post title
- Detect meta value changes when post is updated (post_updated)
- Search everything (posts, pages, tags, cpt, meta)
- Custom field being erased after autosave
- How to select one major category (or custom taxonomy) for a custom post type?
- front end radio custom taxonomy with custom post type
- How to get source of custom meta image?
- Get post info inside modal window?
- Add Taxonomy Values Within a Custom Post Type RSS Feed
- delete custom post based on custom field date
- Displaying Meta Box Image
- Get_post_meta() won’t return value
- Having trouble with custom date field for CPT query (WordPress)
- How to retrieve custom field types for all posts in WordPress/PHP?
- Display posts if a custom field value is equal to another custom field value
- Custom field default value with counter
- wp parse_query not working with custom meta value
- How to use custom fields to enable sticky posts on custom post types?
- Custom meta fields for specific custom type only
- Custom Fields vs Separate Table
- Check if a specific custom field exists?
- WordPress Create Post from front-end
- How to insert content from another Custom Post type into Post?
- Using several custom fields as custom post title
- Copy custom field value to post title
- Custom Post Type + 20k posts = blank/404 within Admin edit.php [duplicate]
- Display custom fields on post excerpt or teaser
- WP_Query orderby modified to include custom meta changes
- How to bulk copy custom fields between custom posts?
- Calculate all custom field values in the post loop
- add custom field to custom post type
- Get image post ID in media upload
- Role scoping for contributors down to the field level
- Having unique constraints for custom fields in a custom post type
- Display custom fields from custom posts in RSS feed
- Rows with custom columns not well formatted after Quick Edit save
- How do I set all of a particular post meta to a value within the custom post type I’m in?
- Can we create a custom post template for a specific page template
- Settings API – save multiple tabs at once
- Send a conditional email notification when a custom field value changes in Post Type
- Add post meta programmatically to attachment
- How to create multiple editor?
- Display post from a date range from custom field
- List of users that clicked a ‘Join’ button at single post
- Get Specific Template Part if Custom Field is Some Value
- Targeting categories in custom fields
- Custom taxonomies to define versions of a product
- Getting a custom post’s custom field based on another custom post’s custom field select
- Inserting custom fields into single.php
- How to make a pulldown menu display custom meta terms in a theme?
- Proceed to the next video of the custom post type but remain on the same post
- search custom post type by custom fields on front end
- Change WordPress custom field default calendar [closed]
- How to show custom field on specific custom post type posts only when filled
- How to copy a custom field from the user’s CPT to the user’s normal posts
- Make a custom column sortable by a value from a different custom post type
- Problem On Retrieving Post Meta Data on Custom Column [closed]
- Need help with simple “if statement” checks to output particlular CPT data depending on what client uploads/fills out
- How can I sort the order of multiple custom field values in a custom post type?
- Checking for custom field in admin pages
- Custom fields array to display it monthly
- Copy data from 2 different ACF custom post types with relation
- Create if else for post types in WP_Query ‘post__in’ values
- How to avoid duplicate posts queried from custom meta?
- custom post types, custom fields and normalization
- Orderby if between two meta fields
- Problem in moving cpt’s from local website to live website
- How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?
- Adding a Section for Visitors
- Automatic Set Category For A Custom Post Type
- Confused about where to store my data
- Sort loop by custom field from different post type
- Meta_query by date for Events archive
- WordPress loop, show only one post per custom field
- Generate slug and meta data if meta field is empty
- one get_posts to return a number of custom posts for each meta value
- Is it possible to make one of two custom fields in Custom Post Type UI Required but not the other?
- Custom Post Type as invoice or order template
- WP_Query get posts where post_name is empty
- Get result from Custom Field in Custom Post type
- Make each Value of custom field show related posts when clicked
- Advanced search form with filters for custom taxonomies and custom fields
- Querying meta values within an array
- Creating entries with image attachements within posts and managing them in a list
- How to Create a Frontend Html-list Editable in the Backend?
- How to grab data (titles, thumbnails and custom fields) from multiple posts to populate a new array efficiently?
- How to get lowest price from custom fields of posts
- Send email on creation of custom post type and use get_post_meta()
- pre_get_posts causes Custom Posts appear under ‘Pages’ menu
- Post object GUID adding http:/
- WordPress does not show the custom fields box
- Query order by a numeric ACF field