Php 从另一个postID拉入块的WP短代码只能使用一次,然后失败
我在这里真的很挣扎。我在函数中创建了下面的短代码,当我在一个页面上使用短代码三次时,它失败了。它只输出第一个,然后在其他两个上失败 有人能看出我在这里做错了什么吗 编辑。该问题看起来是ACF问题。我将短码插入ACF中继器字段,在第一次输出后失败 谢谢Php 从另一个postID拉入块的WP短代码只能使用一次,然后失败,php,wordpress,shortcode,wordpress-gutenberg,Php,Wordpress,Shortcode,Wordpress Gutenberg,我在这里真的很挣扎。我在函数中创建了下面的短代码,当我在一个页面上使用短代码三次时,它失败了。它只输出第一个,然后在其他两个上失败 有人能看出我在这里做错了什么吗 编辑。该问题看起来是ACF问题。我将短码插入ACF中继器字段,在第一次输出后失败 谢谢 function insert_another_page_content($atts) { ob_start(); extract(shortcode_atts(array( 'post_id' => nu
function insert_another_page_content($atts) {
ob_start();
extract(shortcode_atts(array(
'post_id' => null
), $atts));
$post_id = $post_id;
$post = get_post( $post_id );
if ( has_blocks( $post->post_content ) ) {
$content =
$blocks = parse_blocks( $post->post_content );
foreach( $blocks as $block ) {
echo render_block( $block );
}
};
return ob_get_clean();
}
add_shortcode('insert', 'insert_another_page_content');
# [insert post_id="0"]