wordpress添加天气_在WordPress标题之前添加和添加文本

wordpress添加天气

I was thinking about little ways to improve my blog and one small enhancement I wanted to make was adding more information to post titles when they show up in RSS feeds.  Something about notifying the user via title outside of the site itself seemed like a good idea.  For example, some posts are just small "quick tips", and more readers may take the time to peruse it quickly because they know it won't take too long.  Here's how I accomplished that feat with WordPress.

我正在考虑改善博客的几种方法,而我想做的一个小改进就是在RSS提要中显示标题时添加更多信息。 在网站本身之外通过标题通知用户的事情似乎是个好主意。 例如,有些帖子只是一些“快速提示” ,更多的读者可能会花些时间快速阅读它,因为他们知道这不会花费太长时间。 这就是我用WordPress实现这一壮举的方式。

PHP (The PHP)

The first step is creating a function, which is provided the post title and ID, that does a category check and prepends text accordingly:

第一步是创建一个函数,为该函数提供帖子标题和ID,该函数将进行类别检查并相应地添加文本:


function show_as_tip_in_feed($title, $id) {
	if(is_feed() && in_category('tips', $id)) {
		$title = 'Quick Tip: '.$title;
	}
	return $title;
}


Once the function is there, the add_filter hook enables the original function:

一旦函数存在, add_filter挂钩将启用原始函数:


if(function_exists('add_filter')) {
	add_filter('the_title', 'show_as_tip_in_feed', 10, 2);
}


Of course you don't need to do the category check or RSS feed check -- you can append or prepend text to any and every title, and much like other WordPress functionalities, the API easily allows developers to do so.  Win!

当然,您不需要进行类别检查或RSS提要检查-您可以在任何标题中添加或添加文本,并且与其他WordPress功能一样,API可以轻松地使开发人员这样做。 赢得!

翻译自: https://davidwalsh.name/prepend-append-wordpress-titles

wordpress添加天气

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值