admin管理员组文章数量:1429066
I am creating a Gutenberg block, and in the save function I am returning a shortcode. When I click on save the page, a message is displayed: "Failed to update", but when I check the front end it has been saved. What error may be occurring?
save: props => {
return '[custom-shortcode param_1="value_1" param_2="value_2" /]';
}
I am creating a Gutenberg block, and in the save function I am returning a shortcode. When I click on save the page, a message is displayed: "Failed to update", but when I check the front end it has been saved. What error may be occurring?
save: props => {
return '[custom-shortcode param_1="value_1" param_2="value_2" /]';
}
Share
Improve this question
edited Mar 28, 2019 at 21:51
Eduilson Rodrigues da Silva
asked Mar 28, 2019 at 21:22
Eduilson Rodrigues da SilvaEduilson Rodrigues da Silva
336 bronze badges
1 Answer
Reset to default 6What you are looking for is RawHTML to render on the front end.
To use a player shortcode in the post you can use the code below remember that the edit function needs to mirror the markup for the save function for Gutenberg to validate the block.
Include RawHTML:
const { RawHTML } = wp.element;
Save & Edit Functions:
edit: function( props ) {
return (
<div>
<RawHTML></RawHTML>
</div>
);
},
save: function( props ) {
var myShortcode = '[custom-shortcode param_1="value_1" param_2="value_2" /]';
return (
<div>
<RawHTML>{ myShortcode }</RawHTML>
</div>
);
},
本文标签: How to save a shortcode in a Gutenberg custom block
版权声明:本文标题:How to save a shortcode in a Gutenberg custom block? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745498830a2660933.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论