我创建了一个快速的 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/