As far as I am aware, there is no built-in way to get all the posts in a site that contain a specific block.
Two potential things you could do:
- You can use the
has_block()function to determine if a specific post has a specific block. (there is also a more accurateparse_blocks()function available). You could loop over all content and fine posts that contain the block that way (probably not great performance wise). - Add a custom post meta filed that you toggle to true when a user adds the block to the post and false when the user removes the block. Then you can use a custom WP_Query to get posts where the meta value is
true. You can use theuseSelect()React hook to get all the blocks on each post, and check if any have the block you’re looking for. Then use auseEffect()hook to update the meta.
Related Posts:
- Find if widget block is active
- How to disable Widget Gutenberg Blocks?
- Converting a WordPress widget to a block
- Is there an official email form widget or block?
- How to allow your custom widget as block in gutemberg editor
- isSavingPost() for widgets
- Is there any way to parse blocks inside widget area?
- How Migrate a Legacy Widget to block?
- WordPress 5.8 : display new widget
- When editing in block editor, the post/article gets under the floating widgets
- Widget block editor: Unable to collect checkbox values inside widget update() method
- getBlockVariations(…) is undefined in Widget and Template Part editors but not Post Editor
- How to insert a block in a widget which links to a entry/page
- Loading scripts only if a particular shortcode or widget is present
- Add class to before_widget from within a custom widget
- Is there any way to dynamically alter widget titles?
- How to use is_active_widget?
- Show post tags in a widget
- Author template, filter sidebar widgets by author?
- WordPress 4.8: Using multiple WYSIWYG-Editors with media inside of Widgets how to?
- Get page IDs based on which template they are using?
- Add filter to blogroll widget
- Widget Options Not saving
- Embed iframe or html page into dashboard widget
- Loop through widgets in sidebar
- Where to find the source code of a widget?
- How to add author details in the post sidebar?
- Woocommerce Product Category Widget – hide categories that have no products in stock [closed]
- Why will using __construct instead of widget_class_name when creating widget trigger out of memory error
- Role that can edit only widgets, not other theme options
- When to use which plugin output method?
- Hooking Into Widget Output Loop
- Hide widget to non-logged in users without plugin (functions.php) [closed]
- how to extend a WP_widget twice
- Inserting shortcode [stream /] into a Text widget
- How to add css classes to widgets using functions.php?
- WordPress: Apply filter/hook to a particular sidebar widgets?
- How can I add a new CSS class to a widget?
- wordpress widget textbox in the sidebar
- parse json object and display live in wordpress php widget
- Creating a one click demo importer
- Using jQuery in widget development
- duplicate sidebar
- How to check if searchform.php is being included as widget?
- Is it possible to enqueue a script from a widget method (of extended WP_Widget object)?
- How to get sidebar’s content inside admin-ajax?
- Full width layout for custom post type pages
- wp_count_posts, wp_count_terms and wp_count_comments for specific user?
- Why does WordPress stores widget options in a multidimensional array?
- what is option_name on database that store the information of current initiate widget in frontend sidebar?
- Widget – Store and update data
- passing variables inside a widget add_action
- Run JS after widget settings are saved?
- Shortcode displays always first. Once again
- Can I create drag and drop widgets like iGoogle in WordPress?
- Making the default “Latest Posts” WordPress Widget Show Thumbnails
- Text Widget Links Not Working
- Display the id list of active widgets of same sidebar?
- How to remove a widget from the sidebar on specific page?
- When adding a widget, what kind of widget should I used to add images and text and styling?
- Add description to custom text widget and display the 5 recent post titles
- Add individual tag to widget title in sidebar
- Where do I save widget code for wordpress?
- Is there any way to print a widget by having its id?
- How to save widget fields generated from an array?
- Create a widget to use shortcode?
- Remove image height/width attributes from Image Widget
- Need help using a filter on the default Categories widget
- Print owned created widget
- How to display an RSS feed widget inside a page?
- widget dropdown menu code
- Newbie: Help with Vertical Spacing on Footer Widget [closed]
- Content of widgets keep disappearing over and over again
- custom widget does not saved value
- Add visual editor style only on widgets.php page
- php to add a link into wp widget without specific url
- Widget Select Options not saving
- Edit and make class-wc-widget-featured-products.php update-proof
- Display Widgets Horizontally in Area [closed]
- How to overload the update() of existings widgets?
- Proper approach to moving complete site from one domain to another AND preserve widgets
- Static image for embedded YouTube video instead of blank player?
- event organiser not loading in main content area
- Any available action to add content before and after sidebar?
- WordPress widget value not save?
- Console errors in 6.0-RC1 Widget screen
- Fatal error: Uncaught Error: Class ‘WP_Widget’ not found
- Array showing all values of loop instead of specific value to post
- How can I have sidebar widgets on Twenty Seventeen theme on all pages?
- Loop through Widgets in sidebar using widget array number?
- Always show the widget title in a wordpress widget
- Custom php Widget keeps disappearing from the front end
- Display Posts by Views (Popular Posts Widget)
- Default WordPress widgets always appear
- Show editor widgets only on pages that use a specific template?
- Conditionally enable autoplay when using oEmbed in a custom widget
- Options page for widget
- Classic widgets with 5.9+?
- Can’t edit the widgets sidebar or footer
- Custom dashboard widget – load style only for added widget