在wordpress帖子内容的底部添加一些html和php代码
我想在wordpress post内容的底部添加一些html和php代码,我知道通过此函数代码,我可以在post内容的底部添加一些内容:-在wordpress帖子内容的底部添加一些html和php代码,php,html,wordpress,Php,Html,Wordpress,我想在wordpress post内容的底部添加一些html和php代码,我知道通过此函数代码,我可以在post内容的底部添加一些内容:- add_过滤器('the_content','add_before',20); 函数add_before($content){ $custom_content.=''; $content=$content.$custom_content; 返回$content; }如果您有PHP代码,并且希望在HTML文档中运行它,只需使用指示其结束。例如,使用您的代码
add_过滤器('the_content','add_before',20);
函数add_before($content){
$custom_content.='';
$content=$content.$custom_content;
返回$content;
}
如果您有PHP代码,并且希望在HTML文档中运行它,只需使用
指示其结束。例如,使用您的代码
<?php
add_filter( 'the_content', 'add_before' , 20 );
function add_before( $content ) {
$custom_content .= '<div></div>';
$content = $content . $custom_content;
print($content);
?>
<div class='panel-container'>
我将传统上与函数声明关联的return()
语句更改为简单的print()
语句,以显示$content
变量
确保将此PHP放在HTML中希望显示PHP结果的位置。这并没有在你的帖子中指出,但我相信你会有一些想法