Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/266.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在wordpress帖子内容的底部添加一些html和php代码_Php_Html_Wordpress - Fatal编程技术网

在wordpress帖子内容的底部添加一些html和php代码

在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文档中运行它,只需使用指示其结束。例如,使用您的代码

我想在wordpress post内容的底部添加一些html和php代码,我知道通过此函数代码,我可以在post内容的底部添加一些内容:-

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结果的位置。这并没有在你的帖子中指出,但我相信你会有一些想法