-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed as not planned
Closed as not planned
Copy link
Labels
[Feature] Block bindings[Status] Needs More InfoFollow-up required in order to be actionable.Follow-up required in order to be actionable.[Status] StaleGives the original author opportunity to update before closing. Can be reopened as needed.Gives the original author opportunity to update before closing. Can be reopened as needed.[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Description
Description
When retrieving a custom taxonomy field value using get_post_meta() for a taxonomy (e.g. member_type), the function unexpectedly returns NULL, despite the field being populated with valid data in the database. However, dumping the raw data from get_post_meta() shows that the information is stored correctly in the database.
Step-by-step reproduction instructions
- Create and configure the taxonomy field (e.g
member_type) and attach the taxonomy field to a post type and save a term value. - Include this code snippet into your functions.php file:
add_action('init', 'themeslug_register_block_bindings');
function themeslug_register_block_bindings()
{
register_block_bindings_source(
'themeslug/member-type',
array(
'label' => __("Member type", "themeslug"),
'get_value_callback' => 'themeslug_callback_meta_type'
)
);
}
function themeslug_callback_meta_type()
{
$member_type = get_post_meta(get_the_ID(), 'member_type', true);
return $member_type;
}
- Bind a paragraph block:
<!-- wp:paragraph {"metadata":{"bindings":{"content":{"source":"themeslug/member-type"}}}} -->
<p>Meta type</p>
<!-- /wp:paragraph -->
- Attemp data retrieval using
get_post_meta(get_the_ID(), 'member_type', true)to retrieve the term ID associated with the post. get_post_meta()returnsNULL
Screenshots, screen recording, code snippet
No response
Environment info
- WordPress version: 6.6.2
- Gutenberg not installed
Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Please confirm which theme type you used for testing.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
[Feature] Block bindings[Status] Needs More InfoFollow-up required in order to be actionable.Follow-up required in order to be actionable.[Status] StaleGives the original author opportunity to update before closing. Can be reopened as needed.Gives the original author opportunity to update before closing. Can be reopened as needed.[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Type
Fields
Give feedbackNo fields configured for issues without a type.