我的网站上有这个front-page.php页面,我想直接在php页面中放入一个阻止代码。所以我有一个div,我想把它放在那里。但是代码就像
<!-- wp:latest-posts {"postsToShow":3,"displayPostContent":true,"excerptLength":30,"displayPostDate":true,"postLayout":"grid","displayFeaturedImage":true,"featuredImageSizeSlug":"large","align":"wide","className":"tw-mt-8 tw-img-ratio-3-2 tw-stretched-link is-style-default"} /-->
它来自一个小部件。我不能使它工作,请帮助:D
您可以使用函数将块代码插入任何php模板中do_blocks()
,并将(有效)块内容作为字符串传入,例如:
<?php
$block_content = '<!-- wp:latest-posts {"postsToShow":3,"displayPostContent":true,"excerptLength":30,"displayPostDate":true,"postLayout":"grid","displayFeaturedImage":true,"featuredImageSizeSlug":"large","align":"wide","className":"tw-mt-8 tw-img-ratio-3-2 tw-stretched-link is-style-default"} /-->';
echo do_blocks($block_content);
?>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句