Skip to content

Instantly share code, notes, and snippets.

@phpbits
Created June 2, 2023 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpbits/efa38bc29996363b19483aca28850251 to your computer and use it in GitHub Desktop.
Save phpbits/efa38bc29996363b19483aca28850251 to your computer and use it in GitHub Desktop.
import { useSelect } from '@wordpress/data';
/**
* My Custom Block
*/
const MyCustomBlock = () => {
const META_KEY = 'custom_post_meta';
const meta = useSelect((select) =>
select('core/editor').getEditedPostAttribute('meta')
);
const { [META_KEY]: customMeta } = meta;
console.log(customMeta); // Log the value into the browser console.
return null; // Return your block content here.
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment