gpt4 book ai didi

php - 如何将 PHP 返回的输出插入到 HTML
中? (我正在使用 WordPress)

转载 作者:行者123 更新时间:2023-11-30 06:35:24 24 4
gpt4 key购买 nike

我创建了一个快速的 Wordpress 短代码,以便我的作者可以轻松地在帖子的可视化编辑器中设计副标题:

function subtitle( $atts, $content = null ) {
return '<p class="subtitle">' . $content . '</p>';
}

我想将这个输出移动到文档中指定的其他地方,例如:

<div id="output_here_please"></div>

<?php the_content(); /* It is returned here wherever they place the shortcode */ ?>

最好的方法是什么?是否有可以使用的 PHP 或 WordPress 函数,或者我应该创建一个 javascript 来替换 innerHTML(我尝试过这个但不知道如何在页面加载后插入它)。

谢谢

最佳答案

如果你的函数像那样调用副标题,那么他们可以插入它:

<div id="output_here_please">
<?php subtitle("value", "This is some sample content"); ?>
</div>

关于php - 如何将 PHP 返回的输出插入到 HTML <div> 中? (我正在使用 WordPress),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14887451/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com