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
- Trigger Javascript on Gutenberg (Block Editor) Save
- Gutenberg – remove / add blocks with custom script
- 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
- Show control conditionally in Gutenberg
- Gutenberg custom block plugin with custom image sizes
- Get loading state of wp data selector
- How to get the ToggleControl Gutenberg component working for a PHP Block
- Is there a core Sortable component in Gutenberg?
- Hooking a callback into the code within a Gutenberg block
- conditional layout based on if Innerblocks is not empty
- Gutenberg extend blocks add new class name
- 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?
- What do the args for Gutenberg subpackage “hooks” function “doAction” mean?
- How do I fire a snackbar notice in admin?
- Gutenberg Modify core taxonomy panel element via wp.hooks.addFilter
- What is “open()” in MediaUpload?
- Why is this gutenberg custom format button only available from the toolbar as a dropdown?
- Adding a text element in between title and blocks container
- Setting HTML properties in a Gutenberg plugin using WordPress settings
- Gutenberg RichText
- Provide specific example for block variation
- Use useSelect/useDispatch instead of withSelect/withDispatch
- How to handle Gutenberg wp.data async errors?
- Set current tab on a Gutenberg TabPanel component from outside that component
- Block editor: How to check if block editor has initialized and populated the data store?
- How to use wp.hooks.addAction() in React JS/Gutenberg?
- Load script after block is inserted
- Gutenberg block “This block appears to have been modified externally” on save
- 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?
- Gutenberg passing block attributes to component in ES6/ESNext
- Can the index.asset.php file be used with the enqueue_block_editor_assets action?
- How can I add Block Style support to the core HTML block in Gutenberg?
- var is undefined in a Gutenberg block
- Gutenberg add extra attributes to custom format
- Using wp.data.select get actual tags (not id’s) used in post
- event/callback on block update?
- can a buttongroup have a label?
- How to remove p / br elements from gutenbergs editor
- How to disable inline css styles generated by Gutenberg editor?
- Programatically update posts in database from one block to another using transform
- Gutenberg getMedia() in post query doesn’t return all featured images
- WordPress Gutenberg: Attribute overwritten by block duplicate
- Table block variation with header section activated
- Filtering Gutenberg Components, not Blocks
- Where to include JS library in gutenberg blocks
- 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
- Is it possible to add javascript to template parts
- How to add a new attribute to core wp block editor without npm?
- 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
- Create Youtube embed block with createBlock
- How to add a css class to postTitleWrapper in Gutenberg?
- How to change the selected Template using javascript?
- 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?
- useBlockProps() nests wrapper with class name inside block wrapper in the editor
- 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?
- Why Is wp.editor Not Adding the ”Add Media” Button When I Initialize It?
- How to get selected category objects in the block editor?