Skip to content

Instantly share code, notes, and snippets.

@karks88
Last active April 21, 2025 17:06
Show Gist options
  • Select an option

  • Save karks88/23e2fcf8c261c11df95ac6ac99ec0f8a to your computer and use it in GitHub Desktop.

Select an option

Save karks88/23e2fcf8c261c11df95ac6ac99ec0f8a to your computer and use it in GitHub Desktop.
Block Bindings - Register Post Meta
// Register a Custom Field - Add to your theme's functions.php or a custom plugin.
function register_now_playing_meta() {
// Slug: now_playing
register_meta( 'post', 'now_playing', array(
'type' => 'string',
'single' => true,
'show_in_rest' => true, // Makes the field available to the Block Editor.
'sanitize_callback' => 'sanitize_text_field', // Sanitized for better security.
));
}
add_action( 'init', 'register_now_playing_meta' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment