You could consider running actions.getPosts
on mount via data-wp-init
like:
<div … data-wp-init="actions.getPosts">
As per the documentation:
This directive runs a callback only when the node is created.
You could also consider server-rendering the initial set of posts, like:
<div data-wp-watch="callbacks.renderContent">
<?php
$query = new WP_Query(
array(
…
)
);
?>
<?php while( $query->have_posts() ) : ?>
…
Related Posts:
- How to add more elements to an already existing section in Gutenberg
- Working with a non-React external library in a custom block
- Masonry gallery block is working in the block editor but not the template editor
- How to import the imagesLoaded and Masonry libs that come with WP in a Gutenberg block?
- Embedded data and the _fields parameter in getEntityRecords
- Force-update the meta variable first set using `var [ meta, setMeta = useEntityProp( ‘postType’, postType, ‘meta’ );`
- How to build BOTH non-block components and blocks present in the /src directory using @wordpress/scripts
- How to add an additional dependency to a block index.asset.php file
- Why is the Gutenberg editor not recognizing my updates?
- How to transform a shortcode into a block
- How to re-render Gutenberg component when object instance is available
- useSelect() plus resolver result is serving cached data incorrectly
- Gutenberg DatePicker component with time set to zero
- How to render HTML content using the Interactivity API?
- Extend WordPress Gutenberg core/navigation-link
- How to auto rename JS files to prevent browser cache issues
- What are all the query parameters for getEntityRecords?
- How to use wp.hooks.addAction() in React JS/Gutenberg?
- How to only enqueue block javascript on the frontend when its needed [duplicate]
- Extend core block in Gutenberg
- Get loading state of wp data selector
- Is there a core Sortable component in Gutenberg?
- initial open/toggle PluginDocumentSettingPanel panel in document setting block editor gutenberg
- Is there an equivalent of the PHP function sanitize_key in Gutenberg?
- Correctly handling WordPress core data retrieval in Gutenberg
- Is there a client side API for handling transients or options?
- Gutenberg Modify core taxonomy panel element via wp.hooks.addFilter
- What is “open()” in MediaUpload?
- Adding a text element in between title and blocks container
- Setting HTML properties in a Gutenberg plugin using WordPress settings
- Gutenberg RichText
- How to handle Gutenberg wp.data async errors?
- How to use wp.hooks.addAction() in React JS/Gutenberg?
- How to get value of selected page template in Gutenberg editor?
- How do I access site and block editor state data and use `useSelect()` or `withSelect()` to bind it to my components?
- @wordpress/components Button variants not styled
- Block Editor: How to get title and post content within the WordPress admin UI in Javascript?
- Custom block SelectControl works but equivalent ComboboxControl gives errors – where’s my mistake?
- How can I add Block Style support to the core HTML block in Gutenberg?
- event/callback on block update?
- can a buttongroup have a label?
- How to disable inline css styles generated by Gutenberg editor?
- Gutenberg getMedia() in post query doesn’t return all featured images
- InnerBlocks restricting does not work on nested blocks
- How to transform a legacy widget into a block
- Gutenberg: Block validation Failed Richtext undefined
- Add A Tag To A Post Through JavaScript In Gutenberg UI?
- Gutenberg select categories
- Add custom HTML markup to Gutenberg RichText
- How to return div with custom attributes(Coding a Gutenberg Block)
- Open MediaUpload from external component in Gutenberg
- Get Block Attributes in JSON REST API
- Open Featured Image Modal in WordPress Gutenberg onClick of a button
- Gutenberg extend blocks add new class name
- Using apiFetch for retrieving post data in Gutenberg
- Looping over wordpress meta to create “ ‘s?
- How to display post content in the block editor
- what is the purpose of the namespace argument when customizing blocks?
- Gutenberg consume wp-json data and reflect in frontend the content
- How can I import one custom block into another?
- Gutenberg Blocks: how to determine an index of the current inner block?
- Get terms of a taxonomy using useSelect
- Gutenberg select excerpt, use generated excerpt or use more block excerpt
- Gutenberg dependencies in package.json
- find out reason of “Updating failed” in Post-editor
- Gutenberg RangeControl
- Problem extending a core block
- Cannot read properties of undefined (reading ‘show_ui’) Error on WordPress Post Editor
- Add a Page Screen is Visually Blank
- Gutenberg sidebar show input field on toggle
- Get the ID of a page in Parent combobox in editor
- Uncaught TypeError: r is not a function
- Issue migrating a checkbox-type meta field to the block editor
- Update block once an API request returns with a value
- How do I make a savable preview like Youtube Gutenberg block?
- iFrame onLoad in custom Gutenberg block
- WordPress Gutenberg: Attribute overwritten by block duplicate
- How to delete child block for associated parent block
- Passing object to FormTokenField suggestions
- How to detect if we are in the Site Editor part of the Block Editor (as opposed to editing a Page/Post) in JavaScript?
- How can I show a Slot/Fill in the block editor
- How do i get an Inline style in Gutenberg Block show up in front end?
- WordPress adds and tags into HTML blocks after saving
- How do i fix type error
- Gutenberg core/file add style support in js/ json
- How to add a css class to postTitleWrapper in Gutenberg?
- Event when Modal is opened/visible
- Additional CSS classes not being added in Gutenberg editor
- How do I filter/modify the updated content on save using javascript?
- config @wordpress/scripts with webpack and postCSS features
- Jest Unit tests for High order component containing Block Editor
- Separate typography controls for titles and meta in a custom block?
- Include Block Variation Within InnerBlocks
- Gutenberg block: add a multi-select for posts
- Cannot call a class as a function in block plugin react component
- How to execute some javascript code in the editor when a block pattern is added?
- configure additonal build files in the @wordpress/create-block
- Metabox conditionals depending on post format and template in Gutenberg
- How to access current discussion settings in gutenberg via JS?
- How to get selected category objects in the block editor?