正确的位置是functions.php。您添加一个过滤器,如下所示:
function add_post_content($content) {
$content .= $buttonCode
return $content;
}
add_filter('the_content', 'add_post_content');
希望这会有所帮助,杰森
[更新]
为此,我假设您提供的代码是按钮代码,如果不是,则只需替换为正确的按钮代码。
在主题文件夹中打开您的 functions.php 并将其添加到底部:
要将其放在您添加的帖子下方:
function add_post_content($content) {
$buttonCode = "<div data-bg-color=\"#fdfdfa\" class=\"rdbWrapper\" data-show-read=\"1\" data-show-send-to-kindle=\"0\" data-show-print=\"0\" data-show-email=\"0"\ data-orientation=\"0\" data-version=\"1\"></div><script type=\"text/javascript\">(function() {var s = document.getElementsByTagName(\"script\")[0],rdb = document.createElement(\"script\"); rdb.type = \"text/javascript\"; rdb.async = true; rdb.src = document.location.protocol + \"//www.readability.com/embed.js\"; s.parentNode.insertBefore(rdb, s); })();</script>";
$content .= $buttonCode
return $content;
}
add_filter('the_content', 'add_post_content');
要将其放在您添加的帖子上方:
function add_post_content($content) {
$buttonCode = "<div data-bg-color=\"#fdfdfa\" class=\"rdbWrapper\" data-show-read=\"1\" data-show-send-to-kindle=\"0\" data-show-print=\"0\" data-show-email=\"0"\ data-orientation=\"0\" data-version=\"1\"></div><script type=\"text/javascript\">(function() {var s = document.getElementsByTagName(\"script\")[0],rdb = document.createElement(\"script\"); rdb.type = \"text/javascript\"; rdb.async = true; rdb.src = document.location.protocol + \"//www.readability.com/embed.js\"; s.parentNode.insertBefore(rdb, s); })();</script>";
$content = $buttonCode . $content;
return $content;
}
add_filter('the_content', 'add_post_content');