我已经搜索了很长一段时间,以找到一种方法来按日期限制 WordPress 标签,并按它们在选定时间范围内出现的次数对它们进行排序。但我一直比较不成功。
我想要实现的目标类似于 Twitter 上的热门话题。但在这种情况下,“趋势标签”。默认情况下,wordpress tagcloud 显示有史以来最流行的标签。这对我来说没有意义,因为我想跟踪当前的趋势。
理想情况下,它会是这样的:
今天最受欢迎的标签
- 奥巴马(18 次提及)
- 纽约(15 次提及)
- 钢铁侠(11 次提及)
- 罗宾汉(7 次提及)
然后乘以“本周最受欢迎”和“本周最受欢迎”月'。有谁知道如何实现这一目标?
I've been searching for quite a while now to find a way to limit wordpress tags by date and order them by the amount of times they appeared in the selected timeframe. But I've been rather unsuccesful.
What I'm trying to achieve is something like the trending topics on Twitter. But in this case, 'trending tags'. By default the wordpress tagcloud displays the most popular tags of all time. Which makes no sense in my case, since I want to track current trends.
Ideally it would be something like:
Most popular tags of today
- Obama (18 mentions)
- New York (15 mentions)
- Iron Man (11 mentions)
- Robin Hood (7 mentions)
And then multiplied for 'most popular this week' and 'most popular this month'. Does anyone know of a way to achieve this?
发布评论
评论(4)
好的,所以我想您可能想要的是对最后 50 个帖子执行此操作。
循环遍历最后
n
个帖子,提取每个帖子的每个标签的term_id
,然后将该字符串传递到 include 参数中="http://codex.wordpress.org/Template_Tags/wp_tag_cloud" rel="nofollow noreferrer">wp_tag_cloud()
;Okay, so what I think you probably want is to do this for say, the last 50 posts.
Loop over the last
n
posts, extract theterm_id
of each tag for each post, then pass that string into theinclude
argument ofwp_tag_cloud()
;我很确定标签没有时间戳 - 也许您可以搜索特定时间段内具有特定标签的帖子?
I'm pretty sure that Tags does not have timestamps - perhaps you could do a search for posts with specific tags for a certain timeperiod?
我认为你可以查看一些插件,看看是否有你需要的插件
I think you can look at some of the plugins and see if your have a plugin like what you need
您可以通过查询获取标签列表,这样您就不必循环抛出最后一个帖子。
Yo can get the tag list with a query so you don't have to make a loop throw the last X post.