If I understand it correctly, you can use a recursive function which loops through inner blocks to find the specific block. Example:
/* Sample usage, assuming $post is defined properly:
$blocks = parse_blocks( $post->post_content );
wpse_387661( $blocks );
*/
function wpse_387661( $blocks ) {
foreach ( $blocks as $block ) {
if ( ! empty( $block['innerBlocks'] ) ) {
wpse_387661( $block['innerBlocks'] );
} elseif ( 'custom/block' === $block['blockName'] ) {
echo apply_filters( 'the_content', render_block( $block ) );
break; // this could mean that inner blocks were never looped
}
}
}
Related Posts:
- How to serialize a Gutenberg block from block attributes in PHP?
- Removing Default Gutenberg Blocks, But Keeping Reusable Block Functionality?
- is_admin returning false in backend in server side rendered block
- Gutenberg Blocks doesn’t render correctly when using do_blocks
- add_meta_boxes action with refresh on save
- Gutenberg custom block using only register_block_type() and HTML
- Include a Gutenberg Block in a PHP file
- Create custom blocks for bootstrap
- How to return output of the new wp gallery block for automatically Link images To Media file
- Register JS for block on frontend only
- Displaying admin notices inside the block editor from rest_after_insert_{$this->post_type} hook
- How to programmatically add Gallery Block to Existing Post Content
- Best way to add more options to Gutenberg “More Rich” text controls drop down
- Fetch post block/field data as JSON with WordPress API
- Gutenberg block – Save PHP function’s output as HTML?
- Where to find documentation for CPT block template? (PHP)
- Generate YouTube image thumbnail in a Gutenberg block – ACF + Timber
- Add class to group inner container
- Multiple requests external data api dynamic block gutenberg
- How to keep the capability of users and disable Gutenberg editor in WordPress?
- Passing the name of selected color from the custom component to `render_callback`
- InnerBlocks with allowedBlocks not working with acf_register_block
- Guttenburg and Classic Editor – How to use the custom guttenburg block in classic editor?
- How to render a block from php template
- Want to unrestrict plugin block
- WordPress – Get Posts with Category data
- Additional file upload in Gutenberg page options/featured image
- Add Block Before Entry Title Using PHP
- How to populate a Gutenberg select field SelectControl with option value from PHP array
- Gutenberg Blocks and get_option() for styling
- How to extend SelectControl with data from my theme
- Copying and pasting to WordPress “code editor” code via the front end and clipboard
- Gutenberg block don’t save rich text content
- Is there a PHP function that will return the block ID generated by WordPress?
- register_block_type is not working properly
- Categories does not show Block editor WordPress
- Block that renders html saved in a php file
- Show Gutenberg facebook embed with a custom theme
- Gutenberg – render_callback does not pass ToggleControl value on frontend
- Add default block css when the block has been added with php?
- Custom Post Type doesn’t have template content when creating programmatically in PHP but does when created in WP Admin
- How to add different menu items on different menus?
- How to enable REST API on custom post type without Gutenberg?
- Replace block content with an array
- Include a static block inside of a dynamic block
- WordPress Block Editor Gutenberg running code inside ! is_admin()
- Fatal error: Call to undefined function mysql_connect()
- How to Add Image to WordPress RSS-Feed with no Plug-in?
- Childs PHP files not overwriting Parent’s PHP files
- How to add active class to custom menu using while loop and wp_list_pages
- How can I run a .php file located in my site’s root folder?
- Get list of WP Updates Across Sites
- Woocommerce HTML email option unavailable
- Use template for posts with a particular category grandparent
- How to start a script from cli within wordpress
- What’s the best user registration library to integrate WordPress?
- Missing sidebar parameter “fix” – before_content
- WordPress add post format support not working
- Page Automatically Generated from Theme?
- Adding Custom Slider
- Displaying custom taxonomy on WooCommerce product page
- conditional logic for front-end custom field edits
- Custom posts in different columns style
- php syntax : [ && ] between commands [closed]
- Insert custom PHP head above in WP pages
- Can we count the WordPress Loop
- Fixing Memory Leaks in WordPress (HHVM)
- How to remove sidebar primary widget on Mobile on category page [closed]
- Environment to do updates to legacy (4.7) version of WP while staying on php 5.6?
- How can I count ACF sub_field with a certain value
- Custom Registration username_exists / email_exists
- WordPress language switcher doesn’t work
- Search.php gets metadata from first post
- Using Ajax to submit a form, and run a SQL Select query based on user input from the form
- WordPress Multisite login_redirect to primary blog and specific page based on role
- Pagination at category doesnt work with same name of page
- Date translation doesn’t work
- Is it secure to use SMTP password in .php file in WordPress website?
- WordPress add custom search
- Infinite loop when logging out using custom login form
- add custom metabox to media library custom widget
- wp_signon works local, not on https
- Get WordPress username to customize url
- add_action in wp_head accessible from class
- WP_Query To Display Product Of Brand On Taxonomy Page
- Let user select the number of posts shown per page jquery error
- How to have more than one ID included in the exclude command?
- Search for images that width and height is more than 500
- Can’t make product images clickable
- wordpress ajax return 0
- I need help implement a Javascript code into the PHP file
- Admin bar nodes
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- if is_home(), change class of menu-item-225 of wp_nav_menu
- WordPress most commented posts of last X days
- How to check if a value exists in one of two database tables
- What is the wrong with this function to enqueue the scripts and styles to the theme? [closed]
- How to use multiple 404 Error Pages in WordPress
- Parse error: syntax error, unexpected ‘}’ in
- AJAX WP_Query’s order and orderby parameters not working