You can iterate on your parsed blocks to get the right block.
$blocks = parse_blocks( $post->post_content );
foreach ( $blocks as $key => $block ) {
if ( 'block_xxxxx' === $block[ 'id' ] ) {
// do some action here
}
}
Related Posts:
- Removing Default Gutenberg Blocks, But Keeping Reusable Block Functionality?
- Add class to group inner container
- How to keep the capability of users and disable Gutenberg editor in WordPress?
- Add Block Before Entry Title Using PHP
- Gutenberg block don’t save rich text content
- register_block_type is not working properly
- How to add different menu items on different menus?
- Replace block content with an array
- What is This esc_html_e() i wordpress php?
- static variable loop not working in WordPress
- Should the value of core functions be escaped before outputting?
- Woocommerce auto cancel On-Hold after X days
- Add custom field to attachments in a specific category
- Why does “get_option” pull in the older value in options.php, rather than the newer value, on submission of a form?
- Enqueue less file not working in child theme?
- Show last 5 posts from specific category
- Removing unnecessary wordpress files
- Displaying Logged-In User Name and avatar in WordPress Menu
- Change links automatically to affiliate links
- How to make thumbnail image fit into a div where image dimentions are completely different?
- Use is_product_category() properly
- Theme Options: If There is No Input, Don’t Display?
- Placing raw HTML inside a WordPress shortcode
- Word Count Function Preventing Permalink Editing
- Convert all images to PNG on file upload
- If search results empty then execute certain code
- Way to querry data (tags) from a wordpress database?
- Changing custom logo link
- Using fwrite() and “a” appends multiple times instead of once
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Add a variable in functions.php and call it in single.php
- How does WordPress insert Paragraphs in posts
- Linking text within textarea of custom meta box
- Making BuddyPress Activity Stream (Post Type) Featured Images Clickable [closed]
- what is the best practice to add new field to an api route
- Auto-update products after they were published – Woocommerce
- Keyword checking in Gravity Forms
- how to refresh div on template part?
- Child page menu in sidebar
- Title Case WordPress Menu Items
- Alter required message using comment form api
- How to get Post Type from the functions.php file
- Edit the_category (); for a hierarchical display
- Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args
- Why does this update_post_meta function not delete the custom field itself?
- Using data sent via AJAX in multiple functions on a WP plugin
- Detecting if parent page has gallery
- Utilize Function in Child Theme / Template File
- How to have different site identity logos on each page on Astra Theme [closed]
- Removing “Powered by” footer using child theme PHP [closed]
- Overide Variable in Child Theme
- child parent styles enqueue order
- Add URL parameter to all internal links using a specific theme
- Randomize Color Scheme Selection in Theme
- Include a file that has a function in it
- Execute Jquery when a specific page in my plugin is loading
- AJAX function not working [closed]
- How to preload header logo image in WordPress? like what’s the code and where do I put it?
- Contain multiple page templates in one PHP custom template file in WordPress?
- How do I reopen the (Popup Maker) after entering the correct password for a password protected page?
- Display metabox galleries on specific page template in admin editor
- display condition based on post term and status
- Only the first image uploads
- PHP multiple forms, same page, isset($_POST[]) not working?
- Outputting post content to jQuery .html() string
- shortcodes, custom php and their errors
- Categories does not show Block editor WordPress
- In a foreach loop, how can I add a meta value if it doesn’t exist?
- Where do I implement this display of User Meta Data, and how to put it in a table?
- Remove node from multisites?
- How to include a function in a template with template tag
- wordpress all post filter by year
- Add ID to output only for first option
- How to add custom text near category/tag title in WordPress Twenty Fifteen Theme?
- Display text of price (minus 20%) on every product page in a sentence.
- How do I get the featured post to share on Social Media and show on Individual Post pages?
- How to make 2 similar functions more efficient
- Echo multiple tasks if a common function exists
- Add end mark at the end of every article
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- Functions are causing errors
- Global variables and re-use
- Issues separating my Plugin pages into different files
- Link to external page has wordpress blog-url inside
- AJAX: WordPress filters inside $html do not work as intended
- Too few arguments to function woocommerce_update_product_acf_save_post()
- WordPress Importer Call to undefined function set_time_limit()
- Display terms on product page with shotrcode
- Stop breadcrumb function retrieving custom post type template name
- Slug not being updated using wp_insert_post
- Hide child of parent categories already hidden with “get_terms_args” – Woocommerce
- The search doesn’t work properly
- Add attribute to featured image with filter (wp_get_attachment_image_attributes)
- get second ID from array
- How do I get a function to work in single.php
- WordPress different custom tag being displayed in on tag list
- Include a static block inside of a dynamic block
- Exclude a category ID from the following function
- Add text below WooCommerce short description if metabox value is true
- ACF number less than comparison not working