WordPress网站建设的过程中,有时候站长朋友们需要在所有文章的底部添加自定义内容,比如注明文章是本站原创的,提醒别人在转载的时候请注明出处。今天我们就向大家介绍一下实现的具体方法。
切换到主题目录,打开 functions.php 文件,加入以下代码即可:文章源自小柒网-https://www.yangxingzhen.cn/6674.html
//在所有文章底部添加自定义内容function add_after_post_content($content) {
if(!is_feed() && !is_home() && is_singular() && is_main_query()) {
$content .= '你需要添加的自定义内容';
}
return $content;}
add_filter('the_content', 'add_after_post_content');
第 3 行代码使用了条件标签,禁止Feed和首页输出自定义内容。文章源自小柒网-https://www.yangxingzhen.cn/6674.html 文章源自小柒网-https://www.yangxingzhen.cn/6674.html
历史上的今天
4 月
6
- 2023Consul操作使用 WordPress美化最后更新:2022-11-23