前言介紹
- 這款 WordPress 外掛「TDO Tag Fixes」是 2007-12-19 上架。
- 目前有 100 個安裝啟用數。
- 上一次更新是 2008-07-04,距離現在已有 6446 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 2.3 以上版本才可以安裝。
- 有 1 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
tag | tags | fixes | tag cloud | intersection |
內容簡介
這個外掛程式僅用作實現標籤和分類的交集的示例。然而,在最近它增加了一些功能。請隨意在您的外掛程式中重複使用該代碼。這個外掛程式是基於此處的信息。
版本0.5啟用了真正的「或」標籤交集功能。當使用分類時,這一點之前不起作用(且沒有人注意到)。感謝Joel Giddey的發現。
WordPress 2.3引入了原生的標籤支持,非常棒。
但是您知道您可以在同一個存檔中顯示多個標籤,甚至生成一個供此用途的內容嗎?
“http://your-blog-uri/?tag=tag1,tag2”這將獲取所有標記有標籤1或標籤2的文章。
“http://your-blog-uri/?tag=tag1+tag2”這將獲取所有標記有標籤1和標籤2的文章。
“http://your-blog-uri/?tag=tag1,tag2&feed=rss”這將為標籤1或標籤2標記的所有文章生成RSS訂閲。
很不錯,對吧?但是您是否注意到在生成的標籤頁面上,您只能看到標籤列表中的一個標籤?這個函數解決了這個問題,它顯示用於生成該標籤存檔的所有標籤。它通過默認修改single_tag_title模板標籤實現。它甚至可以在由該頁面生成的RSS訂閱上工作!
接下來,可能也會很酷的是能夠交集分類和標籤,這樣您就可以抓取帶有特定分類的標籤文章?
您可以使用此外掛程式實現這一點。但它並不完美,只允許在單個分類和一個或多個標籤之間進行交集。在技術上,WordPress應該支持多個分類和標籤的交集,但在WordPress 2.3.x和2.5中卻無法工作。
因此,轉到您的某個分類頁面。如果您使用的是漂亮的永久鏈接,則在URL末尾添加「?tdo_tag=a_tag」。如果您未使用永久鏈接,則可以使用「&tdo_tag=a_tag」。您必須使用標籤別名,而不是完整的標籤名稱。如上所述,您可以使用「,」和「+」使用多個標籤。
不使用漂亮的永久鏈接的示例:「http://your-blog-uri/?cat=35&tdo_tag=tag1,tag2」,這將獲取ID為35的分類中標記為tag1或tag2的所有文章。
使用漂亮的永久鏈接的示例:「http://your-blog-uri/category/mycategory/?tdo_tag=tag1+tag2」,這將獲取標記為tag1和tag2且在分類「mycategory」中的所有文章。
此外掛程式使用此交集代碼自動修改內置的標籤雲模板標籤wp_tag_cloud,因此如果它在分類存檔中使用,它僅顯示該分類中的標籤。然後,您可以在標籤雲中單擊標籤,它會為該標籤獲取帶有該標籤的該分類中的文章。(您可以禁用此功能,僅按需要使用特定模板)。
一些更多的標籤技巧
如果您想在使用tdo_tag生成的頁面上對結果進行排序,只需將orderby和order附加到URL即可。例如:
“http://your-blog-uri/?cat=35&tdo_tag=tag1,tag2&orderby=title&order=asc“
感謝Tobias Ross。您當然可以將其放入漂亮的永久鏈接,如果您願意進行一些編輯。
版本歷史
v0.5:2008年7月4日
修復了全局變量可能存在的問題
為具有“或”標籤功能的標籤添加了支持
原文外掛簡介
This plugin is simply intended as an example of how to implement tag and category intersections. However it has got a bit more feature-heavy recently. Please feel free to re-use the code in your plugin. This plugin is based on information found here.
Version 0.5 enables true ‘or’ tag intersection when using a category. It wasn’t working prior to this (and no-one noticed). Thanks to Joel Giddey for spotting it.
WordPress 2.3 introduced native tagging support, which is rather nifty.
But did you know that you can display multiple tags in the one archive and even generate a feed for that?
“http://your-blog-uri/?tag=tag1,tag2” this would get all the posts tagged with tag1 or tag2.
“http://your-blog-uri/?tag=tag1+tag2” this would get all the posts tagged with tag1 and tag2
“http://your-blog-uri/?tag=tag1,tag2&feed=rss” this would get you an RSS feed for all the posts tagged with tag1 or tag2
Neat huh? But did you notice that on the generated tag page you see only one tag listed in the header? This function fixes that and displays all tags used to generate that tag archive. It does this by silently modifying the single_tag_title template tag. It’ll even work on the RSS feed generated by that page!
What would be also be cool is to be able to intersect categories and tags so you could grab posts with tags from a specific category for example?
With this plugin you can. It’s not perfect however. It only allows intersection between a single category and one or more tags. Technically WordPress should be able to support multiple categories and tags intersections but it didn’t work for me in WordPress 2.3.x and 2.5.
So go to one of your category pages. If your using using fancy permalinks then at the end of the url add “?tdo_tag=a_tag“. If your not using permalinks then you can just use “&tdo_tag=a_tag“. You must use the tag slug, not the full tag name. You can use multiple tags as above using “,” and “+”.
Example not using fancy permalinks: “http://your-blog-uri/?cat=35&tdo_tag=tag1,tag2” this would get all posts in category with id 35 and tagged with either tag1 or tag2.
Example using fancy permalinks: “http://your-blog-uri/category/mycategory/?tdo_tag=tag1+tag2” this would get all posts in the category “mycategory” and tagged with both tag1 and tag2.
This plugin uses this intersection code to automatically modify the built-in tag cloud template tag wp_tag_cloud so that if it is used on a category archive, it shows only the tags within that category. You can then click on a tag in that tag cloud and it will get the posts for in that category that tagged with that tag. (You can disable this and just use the specific template as you need).
Some more tag tricks
If you want to sort results on page generated by using the tdo_tag you can just append orderby and order to the URL. For example:
“http://your-blog-uri/?cat=35&tdo_tag=tag1,tag2&orderby=title&order=asc“
Thanks to Tobias Ross who figured this out. You could of course stick this in the fancy permalink if you’re okay with doing a little hacking.
Version History
v0.5: 4th July 2008
Fixed a potential problem with global variables
The “or” tag functionality for tags with a category didn’t work. Fixed.
v0.4: 8th April 2008
The tag cloud had a “small” bug, it only gathered the tags from the posts on the first page of the category, not all the posts on the category! Doh. Thanks to Tobias Ross for helping me to get to the bottom of it.
v0.3: 7th April 2008
Small bug fixed. Setting $tdotf_fix_tag_cloud_auto to false did not deactivate the automatic tag cloud modification.
Tag cloud now properly supports exclude, include and number arguments
New template tag: tdotf_the_tags
A basic permalink redirection (as requested)
v0.2: 20th December 2007
Added a tag cloud based on the built-in tag cloud that shows tags from a single category.
v0.1: 6th December 2007
First release
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「TDO Tag Fixes」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
0.1 | 0.2 | 0.3 | 0.4 | 0.5 | trunk |
延伸相關外掛(你可能也想知道)
Post types / taxonomies intersections 》允許創建文章類型和分類法之間的交集,使用URL如下:, mywebsite.com/mypost-type/mytaxo/my-term, 允許使用以下模板文件:, archive-posttype-taxo-term.php...。
