任何问题请联系WX:uu16853

买模板送网站采集器 让你轻松放开双手运营网站!

购买更多有优惠!

在所有WordPress文章底部添加自定义内容

有时候,你可能需要在所有文章底部添加自定义内容,可以将下面的代码添加到主题的 functions.php 文件中:

1
2
3
4
5
6
7
8
//在所有文章底部添加自定义内容
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');

//在所有文章底部添加自定义内容
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和首页输出自定义内容。

关于条件标签,你可以看看:WordPress条件标签(Conditional Tags)

100% Secure Checkout

PayPal / MasterCard / Visa