Check what Gutenberg blocks are in post_content
WordPress 5.0+ has a function for this: parse_blocks()
. To see if the first block in the post is the Heading block, you’d do this:
$post = get_post();
if ( has_blocks( $post->post_content ) ) {
$blocks = parse_blocks( $post->post_content );
if ( $blocks[0]['blockName'] === 'core/heading' ) {
}
}
Related Posts:
- How do I insert a short tag after 350 words in post_content?
- Copy content stored in meta to post content
- How to wrap all titles generated by Gutenberg “Heading” block with tag
- If post content exists (any post content), do not display featured image
- Add data attribute of post_id for Internal links
- replace control character ascii into page
- Get First paragraph only (from page)
- Content area is too small
- How to show NEW post content in post editor?
- get content of author page
- When is the ‘post_content_filtered’ column in database cleared by WordPress?
- Enable Gutenberg on custom post type
- How to get ‘post_content’ without stripping tags?
- Get post content from outside the loop
- How would one modify the filtering Gutenberg applies to pasted content?
- Load CSS/Javascript in frontend conditionally if block is used
- Gutenberg: Is there a way to know if current block is inside InnerBlocks?
- How to extend the gallery block in Gutenberg?
- Custom taxonomy terms not showing as list Gutenberg Editor
- Where can I find the Gutenberg block icons?
- check if Gutenberg is currently in use
- Add pre-publish conditions to the block editor
- How to add a custom CSS class to core blocks in Gutenberg editor?
- How to filter or remove default panels in Gutenberg PrePublish Panel
- Trigger Javascript on Gutenberg (Block Editor) Save
- Running Gutenberg React in Development Mode
- How would I get a taxonomy/category list inside a Gutenberg block?
- Deactivate Gutenberg tips forever – not Gutenberg
- How does Gutenberg handle translations in React?
- Set default image link target in Gutenberg image block
- Removing panels (meta boxes) in the Block Editor
- Gutenberg editor add a custom category as wrapper for custom blocks
- Gutenberg – remove / add blocks with custom script
- post_content with line breaks
- WordPress adding scaled images that don’t exist (1536×1536 and 2048×2048)
- How to remove the core embed blocks in WordPress 5.6?
- Are there Gutenberg container blocks?
- Why is javascript allowed in my post content?
- How to hide specific Gutenberg blocks settings from users
- Add To Gutenberg Sidebar
- Proper way to get page content
- What are all the query parameters for getEntityRecords?
- How to detect the usage of Gutenberg
- How to use PanelColorSettings in custom Gutenberg block?
- show classes as dropdown in guttenberg`s additional css classes input box
- Integrate Gutenberg as a Standalone App
- Creating conditional blocks for WordPress Gutenberg
- Help Unregistering a Core Block Type in Gutenberg
- How to use wp.hooks.addAction() in React JS/Gutenberg?
- How to edit a post meta data in a Gutenberg Block?
- How To Have Two Gutenberg Editors On One Post?
- Gutenberg add a custom metabox to default blocks
- Gutenberg disallow certain custom blocks but keep all core blocks?
- Validation error: Extending Gutenberg gallery block
- How do I register multiple blocks with block.json and register_block_type_from_metadata?
- get_post_gallery with Gutenberg
- Add class to Gutenberg Editor for Custom Post Types
- In Gutenberg, now that withAPIData is being deprecated, how can I do an async call to a custom endpoint?
- Custom action button in Gutenberg editor (post_submitbox_misc_actions – equivalent)
- Remove block styles in the Block Editor
- Disable Gutenberg text-Settings in all blocks
- How do I get the current post ID within a Gutenberg/Block Editor block?
- How to get “Additional CSS Class” for ACF Gutenberg block
- Looking for all available options of Gutenberg Block
- Is there a quick way to remove inline css from all posts?
- Possible to use @wordpress/create-block with multiple blocks?
- Insert Custom HTML After Shortcode
- Are there ways to make the Gutenberg editor wider? And the HTML-block higher?
- Proper, exhaustive documentation for wp.editor etc
- How do I enqueue a script to run inside the Gutenberg editor?
- Blocks: set a default value for a TextControl
- Activate Gutenberg in category-descriptions
- gutenberg block – how to force update after attribute changed?
- How to only enqueue block javascript on the frontend when its needed [duplicate]
- What is the advantage of ‘register_block_type’ (the PHP function) when creating custom blocks?
- Edit srcset and sizes attributes in Gutenberg image, cover and gallery – blocks
- Replacing Gutenberg Featured Image control?
- How to trigger JS in gutenberg page load
- How to make a script load after Custom Block is loaded in the editor?
- How can I extend the Gutenberg table block transform to allow colspans/rowspans on pasted table elements?
- Allow excerpt for pages in Gutenberg?
- Add metabox to document tab in gutenberg
- How to change text size of Gutenberg editor
- How to serialize a Gutenberg block from block attributes in PHP?
- Removing Default Gutenberg Blocks, But Keeping Reusable Block Functionality?
- WordPress Gutenberg Embed Blocks Are Not Responsive
- Is there a list / reference for all current native WordPress blocks?
- Gutenberg: Block validation failed
- Set fullscreen mode by default
- Change Gutenberg category checkboxes to radios
- How to query multiple post types inside Gutenberg options panel?
- is_admin returning false in backend in server side rendered block
- How can I add a custom attribute to Gutenberg core blocks?
- Gutenberg extend core blocks
- Extend core block in Gutenberg
- Setting default font family with theme.json
- Show control conditionally in Gutenberg
- How can I access core/paragraph textColor in a block template
- Is it possible to access Gutenbergs reusable blocks in CPT block templates?
- How to filter by custom post type on Gutenberg “Latest Posts’ block