get_acpt_field
Fetch a field value
Fetch a field value. Returns the value in its native PHP type.
Usage
$value = get_acpt_field([
'post_id' => 123,
'box_name' => 'box',
'field_name' => 'field',
]);Parameters
post_id
integer
Conditional
The post ID
term_id
integer
Conditional
The term ID
user_id
integer
Conditional
The user ID
comment_id
integer
Conditional
The comment ID
wc_product_attribute
integer
Conditional
The WooCommerce product attribute ID
option_page
string
Conditional
The option page slug
box_name
string
Required
The meta box name (or a Custom Content Type table name)
field_name
string
Required
The field name. Use dot notation to reach a nested field, e.g. repeater_field.child_field for a Repeater child, or flexible_field.block_name.field_name for a field nested inside a Flexible Content block
forged_by
array
Optional
Advanced. Used internally to resolve cloned fields
all_users
boolean
Optional
For a User field: return the value regardless of whether the target user still exists
with_context
boolean
Optional
Wrap the returned value(s) in a {before, value, after} object using the field's configured before/after text
format
string
Optional
only_value (default) returns just the value. complete returns the full field object with the value(s) nested inside it
return
string
Optional
object (default) returns relational fields (Post Object, Term Object, User, etc.) as their native WordPress object (WP_Post, WP_Term, WP_User). raw returns the raw stored ID(s) instead. string returns a formatted string
Exactly one of post_id, term_id, user_id, comment_id, option_page, or wc_product_attribute must be provided to identify the location.
Return
mixed
The field value in its native PHP type (string, integer, array, WP_Post, WP_Term, WP_User, WPAttachment, etc. depending on the field type and return)
null
If the field does not exist or has no saved value
Last updated