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
- Programmatically add widgets to sidebars
- Text Widget creates a
- Get Widget Instance inside Widget
- Add the sidebar/widget editor to the post edit screen?
- WP_Widget deprecated error in WordPress V4.3
- What is the quickest way to make a widget?
- Changes in widget customizer not triggering ‘save and publish’
- Remove before_widget / after_widget content from Wp_Widget_Text
- What is the use case for the “Class” parameter in register_sidebar?
- Add a select box to all widgets
- Big side banners
- How to execute SQL SELECT query and see the results?
- WordPress “include TEMPLATEPATH” or?
- Need help adding additional controls to a custom widget Part 2
- How to add the widgets manually to the sidebar?
- How to check if widget has automatic title
- Display sidebar that created in functions.php
- Unable to save widget contents
- Image picker widget
- When you register a sidebar in WordPress, is it possible to choose in what order it appears in the admin
- How to enable “shift-click to edit this widget” functionality on a custom widget?
- WordPress widget args – classname?
- dynamic_sidebar() returns false in admin section
- Moving comments section to left of content (Twenty Thirteen)
- Custom Tag Cloud widget missing tags
- How the widget can be run by shortcode
- add widgets to dashboard for easy access for clients?
- How to add new sidebar widget area to child theme?
- Uses Cases for the Calendar Widget
- Wrap all default widget into div tag
- Problem with widgets
- How to make multi -column, interesting home page in Weaver 2010?
- Widgets missing after update
- Dashboard Widgets – Add Admin Page With Same Functionality
- Help with custom widget options! (saving checkbox option)
- How to filter products using filter products by attribute widget and OR logic between different product attribute types?
- Can you target a widget_class in a register_sidebar?
- Default widgets assignment – isn’t working
- How to add custom widget above admin_footer
- How to create a ‘single’ category widget for woocommerce plugin [closed]
- wp_get_attachment_image() not displaying post images even though wp_get_attachment_url() echo correct urls
- what is the best way to add things to a side bar
- Disable a plugin’s widget
- My Custom Widget does not save in sidebar
- How to add urls in html widget in a gravity form? [closed]
- How to add custom tinymce plugin to new text widget
- What widgets are used on a page? [closed]
- Create Dashboard Widget with form to keep team’s record
- flush_widget_cache is deprecated. Which method should i use instead?
- How not to display an instance of a widget dynamically?
- How to save widget settings on field value change?
- Twenty Twelve Widget Taking Space
- Conditional widget_form_callback
- accessing wordpress serialized data outside wp
- Any advice on customising this twitter feed?
- How to use variables from widgets in other pages?
- Change number of widget columns in dashboard?
- How do I add a small excerpt of a blog post on my Front Page Recent Posts widget?
- How to decorate WP_Widget_Text?
- After adding widget the style is messing up
- Widget title showing below widget
- Siderbar implementation with collapsible bootstrap cards
- Get a list of all Widgets registered in WordPress admin widgets-area
- Simple SCript Not Displayed in WIdth
- how to get value of a select box in custom widget wordpress
- Using the_widget Multiple Times
- Where to add a widget class?
- Does current page contain widget or sidebar
- Nonce and widget
- Active Sidebar Conditional Question?
- Paginate recent posts widget
- How to give a File Upload option in wordpress Widget backend?
- Widget front-end fails to echo as expected from checkbox
- Adding Widgets to Reactor Theme (based on Foundation 4)
- Can I use widgets & shortcode if I need to return an array?
- Widget area does not show any contents for specific users in admin interface. How to go about debugging?
- Help me tidy up my widget code
- Neaten content — different widget or CSS change?
- Custom widget breaking widget section in admin menu
- Unique widget id in sidebar
- Taxonomies not showing in WP Dashboard Right Now widget
- trying to Change to wp_register_sidebar_widget
- How to delete Jetpack Widgets from the Widgets page in admin panel [closed]
- How to customize dynamic_sidebar rendering? [closed]
- How can I order the “Woocommerce Products Widget” by the sales date? [closed]
- Widget does not work with WooCommerce enabled
- How to show WordPress Dashboard Widgets on Frontend?
- How can I add a toggle element into an image box element? [closed]