I want to access the IDs of all posts of custom post type book
in my custom gutenberg block voucher
and then render them in option list
on admin side. What i want to achieve is when i click on voucher
block, a select tag should appear on admin editor with list of posts id of type voucher
. I have read Dynamic block gutenbeg documentation but couldn’t how i can get posts id of custom post type .
this is my code.
wp.blocks.registerBlockType('voucher/shortcode', {
title: 'Voucher Shortcode',
icon: 'smiley',
category: 'common',
attributes: {
category: {
type: 'string',
}
},
edit: function(props) {
return React.createElement(
"div",
null,
React.createElement(
"select",
null,
React.createElement(
"option",
{
value: "animals"
},
"Animals"
),
React.createElement(
"option",
{
value: "arch"
},
"Architecture"
),
React.createElement(
"option",
{
value: "nature"
},
"Nature"
),
React.createElement(
"option",
{
value: "people"
},
"People"
),
React.createElement(
"option",
{
value: "tech"
},
"Tech"
)
)
);
},
save: function() {
return null;
}
})