There are several PostPicker controls.
PostPickerButtonA simple button.PostPickerToolbarButtonA button for use withinBlockControlstoolbar.PostPickerModalThe actual modal interface, that can be integrated into your own UI.
import { PostPickerButton } from '@humanmade/block-editor-components';
...
<PostPickerButton
taxonomies={ [ 'category', 'post_tag' ] }
onChange={ newValue => setAttributes( { postIds: newValue } ) }
values={ attributes.postIds || [] }
/>The LinkToolbar component does not have any custom props other than opensInNewTab, value and onChange, which are all passed on as is to the nested LinkControl component.
The saved values. Array of post IDs.
| Type | Required | Default |
|---|---|---|
Array |
yes | undefined |
The callback to use for handling changing the selected posts. onChange will receive an array of post IDs.
| Type | Required | Default |
|---|---|---|
Function |
yes | undefined |
The title, used by button and modal title.
| Type | Required | Default |
|---|---|---|
String |
no | Select Posts |
Post type to select from.
| Type | Required | Default |
|---|---|---|
String |
no | post |
Taxonomies that results can be filtered by. Array of taxonomy slugs. e.g. [ 'category', 'post_tag' ].
| Type | Required | Default |
|---|---|---|
Array |
no | [] |
There is also a PostPickerToolbarButton component available if you import it directly from the source file, which is intended for use within the BlockControls. It supports all the same props as the PostPicker component, with the addition of an icon.
Button icon. Passed through to ToolbarButton, refer to the documentation of that component for more info.
| Type | Required | Default |
|---|---|---|
string |
no | edit |