admin管理员组文章数量:1332353
I would like to have 3 editable columns (25, 50, 25) like you can insert in Gutenberg, per default in every new page. How can I do this? If I give the columns to page.php
they are not editable.
I would like to have 3 editable columns (25, 50, 25) like you can insert in Gutenberg, per default in every new page. How can I do this? If I give the columns to page.php
they are not editable.
- 1 I am not 100% sure if I understand you correctly, but is it templates you are looking for? developer.wordpress/block-editor/developers/block-api/… – kraftner Commented Dec 18, 2019 at 14:40
- nearly; if i do array('core/columns') and 'page' i get the block with "choose layout" - how to say now "25/50/25" by program to be complete? – Checkpoint Commented Dec 18, 2019 at 16:25
2 Answers
Reset to default 2So first of all this is explained in detail in the documentation, just not exactly for this particular case.
To summarize:
- You want to set a "block template" for the post type "page".
- In this block template you want to have one columns block with 3 column blocks inside with widths of 25%, 50% and 25%
In code this looks like this:
function wpse_354875() {
$post_type_object = get_post_type_object( 'page' );
$post_type_object->template = [
[
'core/columns',
[],
[
[
'core/column',
['width'=>25],
[]
],
[
'core/column',
['width'=>50],
[]
],
[
'core/column',
['width'=>25],
[]
],
]
],
];
}
add_action( 'init', 'wpse_354875' );
Once you are into the column you can add to the column array other blocks that you can identify. Below is another core/paragraph, but you could easily register your own block that grabs the title in an h1 tag (yourOwnBlocks/h1title in the below). I tried this with other block builder blocks and hooray that works too!! Thanks, Kraftner great tip.
[ 'core/columns',
[],
[
[
'core/column',
['width'=>50],
[
['core/paragraph',
[
'placeholder' => __( 'Add Description...', 'wp-rig' ),
],
],
],
],
[
'core/column',
['width'=>50],
[
['yourOwnBlocks/h1title'],
]
],
],
],
本文标签: themesi would like to have 3 default columns editable in guttenberg
版权声明:本文标题:themes - i would like to have 3 default columns editable in guttenberg 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742320843a2452752.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论