admin管理员组文章数量:1317898
I want to show the list of all available custom post types in the settings of the block in admin. How can I do that? Later I want to show a dropdown with those post types which user can select and save.
I want to show the list of all available custom post types in the settings of the block in admin. How can I do that? Later I want to show a dropdown with those post types which user can select and save.
Share Improve this question asked Oct 22, 2020 at 19:09 Imrul.HImrul.H 1752 silver badges14 bronze badges1 Answer
Reset to default 2wp.data.select('core').getPostTypes()
will show return an array of objects that represent each registered post type that is available via the REST API.
wp.apiFetch({path:'wp/v2/posts'}).then( res => console.log( res ) );
will retrieve the latest posts. You may want/need to update the parameters to suit your needs. See the docs for more details
本文标签: How can I list all custom post types in a block
版权声明:本文标题:How can I list all custom post types in a block 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742033853a2416961.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论