WordPress Interactivity API
About
Example of usage:
For Twig: custom.twig
{{ wp_interactivity_state('my-unique-name', {
isHidden: false,
}) }}
<div data-wp-interactive="my-unique-name"
data-wp-context="{{ {'postId': _view.object_id }|json_encode }}">
<div data-wp-bind--hidden="state.isHidden">
My post id is <span data-wp-text="context.postId"></span>
</div>
<button data-wp-on--click="actions.toggle">Toggle</button>
</div>For Blade: custom.blade.php
script.js
Notes
1. WebComponent type setting
2. Interactivity API Basics
2.1) Block name
2.2) Context
2.3) State
2.3) @wordpress/interactivity Package
2.4) Server Side Rendering
Last updated