The solution is/was simple. Use a priority of 1 in the add_filter() function.
function carousel_block_remover( $content ) {
// Matches <!-- wp:client/carousel {"id":"100"} /-->
$regex = '/<!-- wp:client\/carousel {"id":"(.*)"} \/-->/';
if ( preg_match( $regex, $content ) ) {
// Filter the first block out of the_content
$content = preg_replace( $regex, '', $content, 1);
}
return $content;
}
add_filter( 'the_content', 'carousel_block_remover', 1 );
Related Posts:
- Proper, exhaustive documentation for wp.editor etc
- Edit srcset and sizes attributes in Gutenberg image, cover and gallery – blocks
- Add colors to existing color palette without replacing it
- Can you filter posts by meta key with the getEntitityRecords selector?
- WP Gutenberg custom block – generate theme colors from SASS and use them in the inspector and php callback
- create blocks programmtically on theme activation
- Can I customize any WordPress parent block-based theme template files by child theme like a parent classic theme?
- How to support Lazy Loading Assets in a WordPress Theme?
- WordPress Gutenberg Theme: Structure, Hierarchy and Custom Templates
- Gutenberg Reusable Block as part of WordPress Theme page
- Custom button block doesn’t work
- How to float an image in Gutenberg
- Gutenberg – editor-font-sizes in functions not working
- Can’t select my block by clicking on it
- Which file handles the block latest posts, I want to examine excerpt handling
- create-guten-block in wordpress theme?
- What VSCode extensions are there for working with block themes? [closed]
- What is the “correct” way to add hooks or similar PHP behavior to a blocktheme?
- Not able to select width of blocks inside of cover block
- How to check if a WordPress core block is active in sidebar
- gutenberg add classes to list items
- How do you replace content generated by custom fields with custom blocks in Block Editor?
- Custom Blocks as part of a theme
- How to wrap all titles generated by Gutenberg “Heading” block with tag
- How to add InnerBlock multiple times in the same block
- HTML block gutenberg templates
- Gutenberg theme development: how to add “headers” option under styles > colors > elements?
- Change default rel attributes for Image Block & Button Block
- How to update mark-up of a gallery block in a custom theme?
- Auto focus RichText field
- How to create nested array attribute
- Show popover with url and option to open in new window
- How to Modify WP_Includes/blocks/latest_posts.php
- How to render block editor in wp-admin custom pages programmatically
- Social-Link block not loading html on page with custom theme
- How to diagnose wp-env environment problem
- Attribute form NumberControl doesn’t update when I update page before it lose its focus
- WP Gutenberg custom block – generate theme colors from SASS and use them in the inspector and php callback
- Posts Page shows Classic Editor interface not Gutenberg
- How can I include custom Gutenberg Blocks in a theme?
- Block validation failed for `core/pullquote` after adding theme support for editor-color-palette
- Is there a way to add classes to a page when using a Gutenberg reusable block as page layout?
- Correct way to make a custom block theme responsive
- Multiple content areas with Gutenberg – Transparent areas mid content
- Insert gutenberg blocks into template
- Template for posts of category in block theme?
- Can’t select my block by clicking on it on apiVersion – but using blockProps
- How can I use pre declared blocks in a php file?
- Is there any filter or action hook to remove layout classes from appearing in my templates?
- Full site editing templates folder vs block-templates
- How to set the margin on an innerBlock in a block variation?
- Align images to the left of the content
- Image and font support missing in editor when deploying theme remotely
- Why is my Toggle field not showing in Gutenberg?
- When trying to run build script with gutenberg (with SVG import) – Error: Plugin name should be specified
- Block to show posts from same category
- pass object/JSON to wp_localize_script
- Allow Shortcode in Theme Customizer
- Theme Customizer – Nested Sections?
- Where to post/upload the new theme for WordPress theme repository
- Add a notice to users upon first login to the admin area
- Context aware widgets. My work in progress
- Remove “a href” from wp_list_comments()
- Get list of months with posts
- How to list all images in uploads directory except those that are attached to any post
- Advanced theme training?
- Unhook action from child theme
- Does any theme support child theme?
- 2 differen’t menus and it’s using same items in both
- Media Uploader in custom path
- Attach media to multiple posts
- Custom page template with custom fields
- Underscore Based Theme File Permissions in Git
- How do I include pre-installed images in a theme?
- Trackbacks not displaying
- Widget Option is Missing
- If you were to start using a WordPress framework today, which one would you use? [closed]
- Register sidebar ‘before’ and ‘after’ html as div rather than li tags
- Is it possible to have a theme that uses only one single page?
- JQuery undefined and Stylesheet loads in bottom along with js files
- reduce duplicate code in wordpress
- Assign custom classes to the divs inside the loop
- Theme Action to hook for one time only function [duplicate]
- Proper way to move a Bootstrap site to WordPress [closed]
- iPad WordPress theme?
- Adding link post format to theme and permalink to rss feed
- custom Background not showing after upgrade?
- Does single webpage do not need navigation to create a slug in permalink?
- Get gallery images description not work for some images id
- Is a multipurpose theme an alternative to modifying or creating a theme from scratch?
- I want to change the author name
- Does any JavaScript file load automatically for index.php file?
- Display content on Single page
- Trouble creating custom sanitization function when uploading video files
- How to store and retrieve the attachment alignment?
- The content not wrapped in paragraph tags with get_page_by_title()
- Not Found when using activity stream as front page with BuddyPress
- How customizable is a self-hosted WordPress blog compared to a Blogger blog?
- Why we do need wp_enqueue_script() function?
- Is it possible to use “wordpress.org Theme Handbook” look&feel as a theme in my own site? [closed]