Host Unlimited Web Sites for Only $10 per Month! 主機無限網站的只有10元每月!
Powered by MaxBlogPress 本站由MaxBlogPress

WordPress的哈克# 19 :黑客標籤頁| JTPRATT的博客誤區
JTPratt的博客錯誤





Home » Wordpress Hack #19: Hacking Tag Pages » WordPress的哈克# 19 :黑客標籤頁



Posted in: 張貼於:

博客安裝類形象圖片類博客博客,圖片類錯誤WordPress的圖像類WordPress的瑞類形象
628 views 628意見


Please note: This page was originally written in English.請注意:此網頁最初是用英文寫的。

The original post can be viewed原來的文章可被視為 here這裡 .

Please note: This page was originally written in English.

The text has been translated using an online service such as Google or Babelfish.

The original post can be viewed here.


This unique Wordpress hack will allow you to index tag pages you create without having to create template files for each and every one. 這種獨特的WordPress的黑客將允許您的網頁索引標籤您創建,而不需要創建模板文件的每一個。

This post is part of這個職位的一部分 30 Wordpress hacks in 30 days 30 WordPress的黑客在30天內 .

Back in回到 Wordpress Hack #15: Hacking Wordpress Tags WordPress的哈克# 15 : WordPress的標記亂砍 I described how to add “tag support” to your Wordpress theme files, and how to add a “tag cloud” like the one I use on this blog in the bottom of the left sidebar.我描述如何添加“標籤支持”您的WordPress的主題文件,以及如何添加“標籤雲”像我使用此博客在底部的左側欄。 When you “tag” pages you are actually creating additional pages in your blog - that can get indexed by search engines.當你的“標籤”你的網頁實際上是創造更多的網頁在你的博客-這可以索引的搜索引擎。

For example, let’s say that I create a new post about an iPod.舉例來說,我們要說的是,我創建一個新的後一個蘋果。 I put the post in the “gadget” category, and tag it “iPod” and “mp3 player”.我把後在“工具”類別,並標記為“蘋果”和“ MP3播放器” 。 Within the Wordpress paradigm many things happen…在WordPress的範例很多事情...

  1. A new post page is created based on your single.php theme file using the post title as permalink一個新的頁面後的基礎上創建您的single.php主題文件,並使用帖子標題為永久
  2. The post is added to the top of your blog home (usually your index.php home, unless you changed it - like I did)後添加到頂部的博客家園(通常是您的index.php回家,除非你改變了它-就像我沒有)
  3. The post is added to the appropriate archive pages for day, month, year, etc.後加入適當的存檔網頁的一天,一個月,一年等
  4. The post is added to all “category” pages you assigned it to後加入所有的“類”的網頁,你賦予它以
  5. The post is added to all “tag” pages you added it to後加入所有的“標籤”頁面添加到

If you read如果你讀 Wordpress Hack #18: Wordpress Template Files WordPress的哈克# 18 : WordPress的模板文件 , you already know that you can create custom “tag” and “category” pages, so when the old google crawler comes a-knockin’ it will find original content and not penalize your blog in search rankings.你已經知道,您可以創建自定義“標籤”和“類”的網頁,所以當老谷歌抓取來一個敲入'它最終將找到的原始內容,而不是懲罰您的博客在搜索排名。 The problem normally is - if you’re a prolific blogger, you (like many of us) may have a few dozen categories, and hundreds (if not thousands) of tag pages.通常的問題是-如果你是一位多產的博客,你(如我們許多人)可能有幾十類,數百(如果不是千人)標記的網頁。

When you categorize a post, you can find it within your blog at:當您歸類後,您就可以找到它在您的博客為:
www.site.com/category/cat-name www.site.com /類別/貓的名字

When you tag a post you can find it within your blog at:當您標記後,您可以找到它在您的博客為:
www.site.com/tag/tag-name www.site.com /標記/標籤名稱

To create a custom page for any category or tag page, all you have to do is use your index.php or single.php to create a new Wordpress theme file.要創建自定義頁面的任何類別或標籤頁,所有您需要做的就是使用您的index.php或single.php創建一個新的WordPress的主題文件。 Open either index.php or single.php in a text editor and “save as” either:打開任何的index.php或single.php在文本編輯器和“另存為”是:

category-id.php (for category pages)類別id.php (類頁)
or
tag-slug.php (for tag pages)標籤slug.php (標籤頁)

This means if my “gadget” category was “17″ then my theme file for it would be “category-18.php”.這就意味著,如果我的“小工具”一類是“ 17 ” ,然後我的主題文件將是“類, 18.php ” 。 If my tag was “mp3 player”, then my theme file for it would be “tag-mp3-player.php”.如果我的標籤是“ MP3播放器” ,然後我的主題文件將是“標籤的MP3 player.php ” 。 View my查看我的 Wordpress Template Files WordPress的模板文件 hack page for pics and a better description.破解網頁,圖片和更好的說明。

So - What “I” did was create category theme files for every category I had.所以-何謂“我”所做的就是創建主題文件類,每類我。 THEN, I created a single “tag.php” file that would display for every tag page I have.然後,我創建了一個單一的“ tag.php ”文件,將顯示每個標籤頁的我。 What I didn’t mention up until now was that if you create a “category.php” and “tag.php” file and put them in your theme directory that these will be used for ANY category or tag pages that don’t already have one for that slug or ID.我沒有提到直至現在,如果你創建一個“ category.php ”和“ tag.php ”文件放在你的主題目錄,這些將被用於任何一類或標籤的網頁已經不有一個為蛞蝓或身份證。

Every blog is of course a different topic (or niche), but this is what I did for tag pages on one blog I own.每一個博客當然是一個不同的主題(或小) ,但是這就是我所做的標記網頁上一個博客我自己。 I used the tag title to create a different description lead-in sentence to get each tag page listed in the search engines.我使用的標記名稱創建一個不同的描述導致的一句話,讓每個標籤頁中列出的搜索引擎。 Right before “the loop” I placed this bit of code to do that:之前權利“循環”我把這個位的代碼做到這一點:

 <p><?php single_tag_title('This page is about '); ?>! My blog is about geeky tech stuff, technology, Linux, gadgets, web tools, and more! <?php single_tag_title('If you like '); ?>, the posts below should be right up your alley!! 

That code gets the “tag_title” and uses it like this (for the example “mp3 player”):代碼獲得“ tag_title ” ,並使用它這樣的(例如為“ MP3播放器” ) :

“This page is about MP3 Players! “這個網頁是MP3播放器! My blog is about geeky tech stuff, technology, Linux, gadgets, web tools, and more! 我的博客是怪異高科技的東西,技術, Linux操作系統,小工具,網絡工具,以及更多! If you like MP3 Players, the posts below should be right up your alley!!” 如果你喜歡MP3播放器,下面的職位應您的權利胡同! “

I did this a month ago on one of my blogs, and all the tag pages are indexing nicely!我沒有這個在一個月前對我的一個博客,和所有的標籤網頁索引很好! I’m sure you could hack this up even further - but this simple little solution fixed my tag page indexing problem quickly.我相信你能破解這個甚至進一步上升-但這個簡單一點的解決辦法固定我的標籤頁面索引的問題迅速。


Tags:標籤: , , , ,

11 Responses to “Wordpress Hack #19: Hacking Tag Pages” 11日的答复“ WordPress的哈克# 19 :黑客標籤頁”

  1. Erika 埃里卡 Has the following to say...有下列說...

    Yikes… I think you might’ve missed a code tag in your post? Yikes ...我想你可能錯過了一次代號標記在您的文章?

    Erikas last blog post.. Erikas最後的博客帖子.. Miami Web Design邁阿密網頁設計

  2. admin 管理員 Has the following to say...有下列說...

    fixed now - thanks!現在固定-謝謝! = ) ]

  3. Anthonyq Anthonyq Has the following to say...有下列說...

    Another great tip which i’m implementing right now!另一位偉大的小費而我現在執行的權利!

    Question thou : how do you trunticate your listings in the Tag Page order to avoid duplicate content?問你:你怎麼trunticate您的物品在標籤頁,以避免重複的內容?

  4. Mark - The Niche Store Builder 馬克-小商店的建設者 Has the following to say...有下列說...

    Hey man - Glad to see your back!!嗨人-很高興看到你回來! Either I missed a bunch of posts, or you took a vacation!無論我錯過了許多的職位,或者你休假了!

    Mark馬克

    Mark - The Niche Store Builders last blog post..馬克-商店的生態建設者最後的博客帖子. . Creating your Own little WordPress Playground創建自己的小WordPress的遊樂場

  5. jj-momscashblog 殲教momscashblog Has the following to say...有下列說...

    Hi JT, First time here and I’ve enjoyed your posts, full of lots of info.日本煙草公司,您好,第一次在這裡,我也很喜歡您的文章,充滿了大量的信息。 will have to come back and read a couple of others that I thought looked interesting.將回來,並宣讀了幾個其他國家,我認為看上去有趣。 thanks so much .感謝這麼多。 I also wanted to let you know your Entrecard will be on my blog tomorrow, so many thanks for that.我也想讓您知道您的Entrecard將在明天我的博客,這麼多的感謝。 =

  6. admin 管理員 Has the following to say...有下列說...

    @jj-momscashblog - thanks for the kind words, glad to have you here! @殲教momscashblog -感謝客氣話,高興有你在這裡! = ) ]

  7. admin 管理員 Has the following to say...有下列說...

    @Mark - thanks for the comment! @馬克-感謝評論! No - I didn’t post at all last week and only once the week before (too busy!).沒有-我沒有在所有後上週只有一次一周前(太忙了! ) 。

  8. admin 管理員 Has the following to say...有下列說...

    @Anthonyq - I don’t truncate the listings on my tag page (other than maybe excerpt) to avoid duplicate content, it’s just not any issue (in google) anymore. @ Anthonyq -我不截斷我的物品標籤頁(以外的其他可能的摘錄) ,以避免重複的內容,只是沒有任何問題(在谷歌)了。

  9. Anthonyq Anthonyq Has the following to say...有下列說...

    Ah ok.啊確定。 I was looking on your blog here, i noticed that the listings were summaries.我一直在尋找在你的博客在這裡,我注意到,上市了總結。 Wondering how you do that?你想知道如何做到這一點?

  10. Dennis Edell 丹尼斯Edell Has the following to say...有下列說...

    Love these posts.愛這些職位。 I’m saving them all for when I may be confident enough to hack without destroying.我很節省的他們都當我可以有足夠的信心砍不破壞。 :-)

    Dennis Edells last blog post..丹尼斯Edells最後的博客帖子.. Grab Your Offline Marketing Tools Here Too!抓斗您的離線營銷工具在這裡呢!

  11. admin 管理員 Has the following to say...有下列說...

    @Dennis - I would read @丹尼斯-我想讀 showing only a post excerpt in Wordpress只顯示後在WordPress的摘錄 .

Question or Comment??問題或意見? ? Spill it Now...溢油現在...

跳躍的喜悅以上的評論!

We Reward Comments!我們獎勵的意見!


We dofollow links, and get your latest blog post as a byline under every new comment from the "CommentLuv" plugin!我們dofollow聯繫,並獲得最新的博客帖子的署名下的每一個新的評論從“ CommentLuv ”插件! Top commenters for every month are listed on every page of this site in a sidebar widget linked back to your URL!頂端commenters每個月列出的每個網頁上本網站的聯繫欄部件回到您的網址! We would like to reward you for becoming part of our community!我們要獎勵你成為我們的社會! Your comment is valuable not only to us, but also all the other readers of this blog!您的評論是有價值的,不僅給我們,而且所有的其他讀者的博客!


Click to add smilies to your post! 按一下以新增的笑臉到您的帖子! == [ ]^ = (= ( (= ( |= )研究= | 8= 0= ) 〜= 00= (= ; ;= ) ]= ; ; ;