我正在尝试将定制ACF古腾堡积木与立柱上的其他核心积木分开。目前我正在使用the_content();
这抓住了古腾堡编辑的每一块。我现在要做的是查看古腾堡编辑器中的所有块,检查它们是否是自定义ACF块,如果它们是ACF块,则将其输出到其他块,不要输出该块。我目前拥有的是:
$blocks = parse_blocks( get_the_content() );
foreach ( $blocks as $block ) {
if ( \'acf/qd-center-copy\' === $block[\'blockName\'] ) {
echo $block[\'innerHTML\'];
}
}
因此,上述函数所做的是在Gutenberg编辑器中遍历块,检查块名是否为“acf/qd center copy”,如果块名等于“acf/qd center copy”,则输出该块。我遇到的问题是该块的输出,我不确定需要做什么才能正确输出自定义ACF块。
以下是我使用时为块名为“acf/qd center copy”的块输出的内容print_r($block)
:
Array
(
[blockName] => acf/qd-center-copy
[attrs] => Array
(
[id] => block_5caf50e1cda63
[data] => Array
(
[qd_background_color_toggle] => 1
[_qd_background_color_toggle] => field_5c700fe8bb525
[qd_headline] => Test Centered Text block
[_qd_headline] => field_5c70100ebb526
[qd_content] => Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
[_qd_content] => field_5c70101dbb527
[qd_additional_column_toggle] => 0
[_qd_additional_column_toggle] => field_5c701034bb528
)
[name] => acf/qd-center-copy
[align] =>
[mode] => auto
)
[innerBlocks] => Array
(
)
[innerHTML] =>
[innerContent] => Array
(
)
)