admin管理员组文章数量:1333427
I have been searching for a day and still carn't seem to find the right documentation for what arguments I can pass to core components when attempting to configure a CPT block template in php. This is what I have but I want to take this further by nesting buttons and custom html etc. but carnt find the docs I need.
'template' => array(
array( 'core/columns', array(), array(
array( 'core/column', array("width" => "60"), array(
array( 'core/image', array() ),
) ),
array( 'core/column', array("width" => "40"), array(
array( 'core/image', array() ),
array( 'core/heading', array(
'placeholder' => 'Add a inner paragraph'
) ),
) ),
)
)
Found everything needed to create bespoke blocks in JSX but blegh, Not got the time to learn the wizardry ways of JSX just yet and I dont really want new blocks just want the existing one bound as a template to a custom post type.
A good way to example my question, how did this person find the answer on how set the width of this template columns.
How to set column widths in a CPT block template?
How did the person find this answer ? did they have to dive in to the JS scripts of the component and work it out or is there some documentation on this or am I missing something all together.
Any help would be greatly appreciated.
I have been searching for a day and still carn't seem to find the right documentation for what arguments I can pass to core components when attempting to configure a CPT block template in php. This is what I have but I want to take this further by nesting buttons and custom html etc. but carnt find the docs I need.
'template' => array(
array( 'core/columns', array(), array(
array( 'core/column', array("width" => "60"), array(
array( 'core/image', array() ),
) ),
array( 'core/column', array("width" => "40"), array(
array( 'core/image', array() ),
array( 'core/heading', array(
'placeholder' => 'Add a inner paragraph'
) ),
) ),
)
)
Found everything needed to create bespoke blocks in JSX but blegh, Not got the time to learn the wizardry ways of JSX just yet and I dont really want new blocks just want the existing one bound as a template to a custom post type.
A good way to example my question, how did this person find the answer on how set the width of this template columns.
How to set column widths in a CPT block template?
How did the person find this answer ? did they have to dive in to the JS scripts of the component and work it out or is there some documentation on this or am I missing something all together.
Any help would be greatly appreciated.
Share Improve this question edited Jun 27, 2020 at 16:33 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Jun 27, 2020 at 15:11 JohnnyJohnny 555 bronze badges 1 |1 Answer
Reset to default 0You can't find that documentation because it doesn't exist. It doesn't exist because that's not how it works, and it would require extensive duplication to set up.
So to figure out what you need to put, figure out what it is in Javascript/JSON, then translate it to PHP.
The pattern is:
[
'block name'
[
'parameter': 'value'
.... etc
],
[ .... child blocks ... ]
]
Which brings us to why there is no doc that explicitly mentions these parameters for PHP. Those parameters aren't defined in PHP, they're defined by the blocks themselves, and the blocks are built in javascript. So you won't find a list of parameters for use in PHP block templates, because there isn't one, and it would not make sense to make one. That's not how it works.
So, build your blocks in the block editor, look at their parameters, then write them in in PHP.
A good way to example my question, how did this person find the answer on how set the width of this template columns.
By inspecting the blocks in the editor to see what the parameters of the block were, and what their values were.
本文标签: Where to find documentation for CPT block template (PHP)
版权声明:本文标题:Where to find documentation for CPT block template? (PHP) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742313633a2451370.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
array()
becomes[]
( note that[]
is valid in modern PHP versions ) – Tom J Nowell ♦ Commented Jun 27, 2020 at 15:18