getBlockParents
will work accurately. You can use getBlockParents
with the clientId
of the block, getBlockParents
will return the all parent blocks id if the current block is under any Blocks. It will return blank if current block is not under any Block
here is a method that you can use:
const innerBlock = "namespace/block-name";
const parentBlocks = wp.data.select( 'core/block-editor' ).getBlockParents(props.clientId);
const parentAttributes = wp.data.select('core/block-editor').getBlocksByClientId(parentBlocks);
var is_under_inner = false;
for (i = 0; i < parentAttributes.length; i++) {
if ( parentAttributes[i].name == innerBlock ) {
is_under_inner = true;
}
}
//console.log(is_under_inner);
Related Posts:
- How would one modify the filtering Gutenberg applies to pasted content?
- How to add a custom CSS class to core blocks in Gutenberg editor?
- How can I extend the Gutenberg table block transform to allow colspans/rowspans on pasted table elements?
- Changing text within the Block Editor
- Remove left alignment option in core/image block
- Changing Gutenberg / WP block editor width only on pages, not posts or other taxonomies
- Filter Gutenberg Blocks Content
- How do I replace a render_callback function for a block?
- How can I filter block registration based on post-type? (Block alignment settings)
- Gutenberg disable the “block” tab in right sidebar
- How to change the order of HTML output of a core block?
- Gutenberg – Add align controls to a custom block
- Can the wordpress color palettes by changed through Javascript?
- Inline Styles on all native blocks
- How to link the whole list item in Gutenberg’s latest posts block?
- add_filter(allowed_block_types) -> adding core/paragraph bugs Gutenberg editor
- Set default terms for new posts / CPTs
- Detect when gutenberg editor title is available in Dom after editor load
- Gutenberg Block – Post Featured Image Filter Hook
- Set default value for “Additional CSS class(es)” for specific block types
- How to hide/remove GhostKit component panel in gutenberg block inspector
- Filter for author list in gutenberg core editor
- How to optionally append components to the output of a gutenberg block?
- Problem width wp_insert_post_data and Gutenberg block editor
- WordPress Gutenberg core/heading block (wp-block-heading)
- Changing the category for existing Gutenberg blocks
- How do I check if I can use the allowed_block_types filter?
- How to add lazy field in content endpoint using Gutenberg blocks
- How to add custom HTML attribute to reusable block div in WordPress admin
- How to change this WP logo and posts url in block editor?
- what is __return_false in filters
- What does (10, 2) mean when used with add_filter
- Clarification on filters and hooks
- Remove “Private” + “:” in title does not work
- Adding a class to the body_class function
- Modify the post/entry wrapper markup in genesis childtheme [closed]
- Where is the proper place to add a filter for pre_get_table_charset?
- Change text of Description in Image Library
- Allowing non-latin characters in registration
- Wrap gutenberg block ‘div’ in other elements/extra HTML
- post_row_actions filter is not working while update post using quick edit
- About Hooks and Filters
- Should I use add_action(‘publish_post or add_filter(‘publish_post?
- How to always display a specific post from the search result first
- get_the_excerpt() with fallback like the_excerpt()
- Adding custom column to comments admin panel?
- Filter out some plugin action in wp head / wp_footer
- check if FILTER(“the_content”) is being executed in `the_post()`
- Change Password Strength Indicator names?
- Filter my args by the post 1st letter
- Limit RSS feed to previous calendar month
- Adding Filter to Homepage only
- How to stop wrapping comments in P tag
- How to modify core when there is no hook?
- Is this the proper way of switching the “Edit My Profile” link with my BuddyPress “Extended Profile” link?
- Does auto_update_plugin Filter Work When Put In Theme’s functions.php File
- In need of a content replace filter for posts in a specific wordpress category
- html tags in gettext hook get escaped
- How to remove action with slashes and arrows?
- How to filter post content and force every link () made in blocks to return urldecode() with readable value?
- Get .subsubsub count of post per status queried using pre_get_posts
- Adaptive product filters for WooCommerce
- Changing WordPress core without hacking core
- Plugin options, presets and filters : can you help me improve my workflow?
- Remove posts inside pre_get_posts using a custom query
- Remove / Hide Attachment Display Settings in Add Media popup / dialog
- Wrapping my head around add_filter
- Is it possible to apply filter to meta key value when querying posts?
- How to add_filter to an OOP based apply_filter(‘foo::bar’, $a);
- apply_filters with multiple args and multiple add_filter
- Help with filter for wp_notify_moderator()
- Change custom post type GUID in RSS
- Conflict calling an add_filter() twice
- Add something after a filter
- Add filter unless it is being called under specific function
- paginate_links() Change the order of links
- Filter / add_action to upgrade.php page
- Add Filter – Pass Variable (PHP < 5.3)
- How do I add a line break to a string that is output by PHP?
- style_loader_tag not changing stylesheet to preload
- add_filter doesn’t return false?
- How to track a particular page in order to address the loading speed issue
- Display posts from today and future in Elementor ‘posts widget’
- Right filter for rewriting page statuscode
- Changing title using filter not working with argument
- Archive Widget – Count only parent posts
- how to overwrite next_post_link
- Cutting off excerpt with first sentence
- Change URLs in default WordPress slider to relative from absolute
- Print url to default featured image
- Change add_filter based on Ajax
- What action/filter can be used for modifying the page to be rendered?
- Adding user filter – Not updating data in URL
- How to add more than one custom metadata as filter on the post list page?
- filter wptexturize doesn’t work on old posts titles
- Add Default WordPress Formatting To Data From External SQL Tables?
- Getting entry ID from frm_email_message filter in formidable
- Auto append text after the title?
- Is there a hook or filter that adds a button to the left of the search box?
- filter a list by gender