admin管理员组文章数量:1296895
I need to insert a set of images already in the media library to the end of the content of each new post.
Instead of inserting the html directly is there a way to add a Gallery block by using the image IDs ?
I've found this piece of code without much explanation for it
var content = "Test content";
var el = wp.element.createElement;
var name = 'core/paragraph';
// var name = 'core/html';
insertedBlock = wp.blocks.createBlock(name, {
content: content,
});
wp.data.dispatch('core/editor').insertBlocks(insertedBlock);
and am wondering if someone can point to some material showing how to do this correctly if it is at all possible to do.
Examples, articles etc - what I've come across has not been helpful. Mostly appending the html to the end of the content.
本文标签: phpHow to programmatically add Gallery Block to Existing Post Content
版权声明:本文标题:php - How to programmatically add Gallery Block to Existing Post Content 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741645079a2390139.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论