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()
- Manipulating the allowed inner blocks of a core-gutenberg-block?
- Adding features to Gutenberg without theme.json
- Registering a custom block style
- Get column block count using PHP method render_block
- do_blocks not working with a custom block
- How to edit templates created in the block editor in code / template files not updating
- Programmatically convert single classic block to individual blocks via PHP
- Add custom data attribute to every core Gutenberg Blocks
- Embed dynamic media query in a Gutenberg block
- Get generated block styles programmatically
- When a foreach loop is used multiple times in blocks, is there a way to ensure a variable always has a unique value?
- How to get the post title inside a custom block in a loop? block.js
- How to display only the first 2 words of a post title
- How to get the content of a dynamic block in PHP
- Set custom post type to load custom block pattern by default
- PHP code in page template vs functions
- Retrieve multiple values passed to a single attribute in a shortcode
- Security – Ajax and Nonce use [closed]
- Routing a custom php on wordpress
- Nice scroll to wordpress
- WordPress Customizer not setting default value upon initial install?
- Blank space at beginning of tag?
- Update PHP version 5.3 to 7.2 or first WP 4.7.11 to 4.9.8?
- Get first URL from post content
- Setting custom canonical urls
- How to output a PHP file values by shortcode?
- PDF file randomly breaks upon upload
- dividing sub-categories by parent category – WordPress
- Return encoded Page Title outside of a loop
- Display all pages – in order
- Backend of the WordPress.com [closed]
- How set a custom URL for a new theme file in WP?
- file_get_contents(includes_url( ‘/js/jquery/jquery.js’ )); not working
- what is the method to echo class attribute inside the i tag? [closed]
- Can’t change website Title on wordpress
- Query for user roles
- Php file that doesn’t recognize wordpress functions
- Set cookie for visitor
- Is there a way to create a “copy post” link?
- Use of antispambot with $curauth->email
- Add a suffix to the image in the_content()
- add role on WordPress in PHP on a second database
- Enqueue assets from multiple directories using add_action/do_action
- Changing Date Format on Custom Meta Data w/shortcode call
- How to redirect (301) trashed post to it’s parent taxonomy TERM ARCHIVE instead of 404 page
- style.min.css code issue
- How to detect and make links nofollow in author description
- Display wordpress post to static website in the footer
- My title is showing after the shortcode
- Display Sale Price Before Regular Price (WooCommerce)
- Using is home to get content [closed]
- Site Health and PHP 8.1
- “acf/load_field” Critical error upon saving/updating WooCommerce products [closed]
- How to improve the performance when using a flat-file dataset and PHP for implementing advanced search function?