Last active
April 21, 2025 17:06
-
-
Save karks88/23e2fcf8c261c11df95ac6ac99ec0f8a to your computer and use it in GitHub Desktop.
Block Bindings - Register Post Meta
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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