Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add attributes to ServerSideRender readme #12793

Merged
merged 2 commits into from
Dec 11, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions packages/components/src/server-side-render/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,25 @@ Output uses the block's `render_callback` function, set when defining the block.

## API Endpoint

The API endpoint for getting the output for ServerSideRender is `/wp/v2/block-renderer/:block`. It accepts any params, which are used as `attributes` for the block's `render_callback` method.

The API endpoint for getting the output for ServerSideRender is `/wp/v2/block-renderer/:block`. It will use the block's `render_callback` method.

If you pass `attributes` to ServerSideRender you must define these attributes when registering the block.
NateWr marked this conversation as resolved.
Show resolved Hide resolved

```php
register_block_type(
'core/archives',
array(
'attributes' => array(
'showPostCounts' => array(
'type' => 'boolean',
'default' => false,
NateWr marked this conversation as resolved.
Show resolved Hide resolved
),
'displayAsDropdown' => array(
'type' => 'boolean',
'default' => false,
),
),
'render_callback' => 'render_block_core_archives',
)
);
```