Free Checking for Bloggers - Sign up in 5 Minutes! 免費檢查的博客-註冊在5分鐘!
Powered by MaxBlogPress 由maxblogpress

在WordPress哈克# 14 : 12的方式侵入您的首頁| jtpratt的博客失誤
jtpratt的博客失誤





Home » Wordpress Hack #14: 12 Ways to Hack Your Home Page WordPress所哈克# 14 : 12的方式侵入您的首頁



Posted in: 張貼在:

博客安裝類的形象在WordPress類的形象
1,446 views 1446的意見


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.


To have a unique Wordpress blog home page you don’t have to create your own theme. 有一個獨特的WordPress所博客主頁您沒有要創建您自己的主題。 I’ll show you 12 ways to hack your homepage without getting a new theme that will make your blog stand out from the pack! 我會向您展示12途徑入侵您的首頁沒有得到一個新的主題,這將使您的博客站出來,從包!

This is installment #14 of這是分期付款# 14 30 Wordpress Hacks in 30 Days 30日在WordPress駭客在30天內 , be sure to sign up to our RSS feed or email updates at top right of this page!W ,一定要進行註冊,以便我們的RSS飼料或電子郵件更新,在右上角的此頁!瓦特

Everyone wants their blog to be different.大家都希望他們的博客有所不同。 You want it to be unique, to stand out, while remain easy to present what it is your blog is about.您希望它是獨一無二的,站出來,而仍然容易,目前是什麼,您的博客。 The same old “rolling list of posts” and obigatory sidebar can get (real) old after awhile.同時,老“的滾動名單的職位”和obigatory欄可以得到(不動產)舊後一段時間。 Out of the box, everybody’s Wordpress blog looks the same, and getting a custom theme is the first stab at breaking out of that box.出於對中,大家的WordPress博客看起來一樣,獲得一個自定義的主題是首次刺傷打破了這個框。 The next step (before creating your own theme from scratch) is hacking that theme up a bit to get more of what you want out of it.下一步(前創建自己的主題,從白手起家)是黑客這一主題了一個位,以獲得更多的是什麼你想出來。 While some of the techniques I’m about to show you can be used on nearly any page in your Wordpress blog, the focus of this article is “ ways you can hack your Wordpress home page!雖然有些技術我約,以顯示你可以用在幾乎任何網頁在您的WordPress所博客,本文的重點是“ 的方式,您可以哈克您的WordPress主頁 ” !

*All the plugins mentioned on this page are *所有插件提到,在這頁 listed on the Wordpress 2.5 Compatibility list* 列於在WordPress 2.5相容性清單*

1. 1 。 Organize posts in 2 Side by Side Columns : Maybe you are tired of that one-column of content on your homepage, and you want more of a magazine or newspaper layout approach. 組織員額在2並排專欄文章 :也許你已經厭倦了一欄的內容在您的首頁上,且您想要更多的雜誌或報紙版面的做法。 If so, breaking up your posts into 2 side by side columns of content could be good for you.如果是的話,打破了您的帖子變成2並排欄目的內容可以很好的給你。 I can’t take credit for this hack, it’s well explained, including where to put the code and which files to edit - over on the我不能採取信貸,為這個技巧,它的解釋,包括把代碼和哪些文件編輯-超過對 Crea8 Design Blog: Side by Side Wordpress Columns crea8設計博客:並排的WordPress欄目 .

2. 2 。 Create Custom Comment Counts : Here’sa hack that I desperately tried to figure out for months and months, and never really found the answer to all in one place. 創建自定義評論計數 :這裡開刀,我拼命試圖弄清楚幾個月內,從來就沒有真正找到了答案,所有在同一個地方。 I ended up finding the answer not in a blog post, but in theme code instead.我最後找到的答案不是在一個博客帖子,但在主題的程式碼,而不是。 Some of the best bloggers sites that I read have some post meta-information in the title header, including a comment count.一些最好的博客網站,我看過有一些職位的元信息在標題中的標題,包括評論。 Usually it’s also a link, and sometimes it has a cool little comment bubble or a phrase like “What do you have to say?”通常這也是一個鏈接,有時它有一個冷靜的小評論的泡沫或一個詞組一樣, “你怎麼有說” ?

Normally to just get a “comment count”, you see code like this in a theme:通常只得到一個“評論計數” ,您會看到這樣的代碼在一個主題:

 <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?> < ? PHP的comments_popup_link ( '沒有評論' , '1評論' , ' %評論' ) ; ? > 

After “comments_popup_link” the text inside the three sets of quotes represents what should be printed out if there are no comments yet, only one comment, or more than one comment.後“ comments_popup_link ”內的文字三套引號代表什麼應印出來,如果有沒有評論,只有一個評論,或一個以上的評論。 You modify the text to say whatever you want here.您修改案文說,無論您想要在這裡。 You could change ‘No Comments’ to ‘Be the first to comment…’, etc. But, if you’re like me you probably want to spice it up a bit and add a nice little comment icon.你可以改變'沒有評論』轉為『成為第一位評論… … '等等,但如果您和我一樣,你可能想要香料起來有點添加一個好一點的評論圖標。 If so, use this code:如果是的話,使用此代碼:

 <?php $comments_img_link= '<img src="/wp-content/themes/mytheme/images/comments-icon.gif"  title="comments" alt="comments" />'; comments_popup_link($comments_img_link .' Comments(0)', $comments_img_link .' Comments(1)', $comments_img_link . '  Comments(%)');?> < ? PHP的美元comments_img_link = ' <img src="/wp-content/themes/mytheme/images/comments-icon.gif" title="comments" alt="comments" /> ' ; comments_popup_link ( $ comments_img_link 。評論( 0 ) '元, comments_img_link 。評論( 1 ) '元, comments_img_link 。評論(%)');?> 

In the first line just change the path your theme image directory and copy and past the code wherever you want the comment count and icon to appear for your home page posts.在第一線,只是更改路徑,您的主題形象目錄,並複製和過去的代碼在何處您想要的評論計數和圖標出現在您的首頁職位。

Unique Ads Between Posts : This technique can be used to place most anything in between the posts in “the loop” on your home page, I used it to display adsense ads after the 2nd and 6th posts (in the loop of 10). 獨特的廣告,崗位之間 :這一技術可用於地方最有什麼之間的職位,在“循環”對您的首頁,我用它來顯示AdSense廣告後,第二和第六個員額(在河套10 ) 。 It doesn’t have to be an ad - it could be used to show image dividers between each post, random quotes, special links - anything.它沒有成為一個廣告-它可以用來顯示圖片分隔之間的每一個職位,隨機行情,特別鏈接-任何事情。

First - I’ll show (again) what “the loop” basically looks like:第一次-我會顯示(再次)什麼是“循環” ,基本上看起來就像這樣:

 <?php if (have_posts()) : ?>  <?php while (have_posts()) : the_post(); ?>      <div class="post" id="post-<?php the_ID(); ?>"> <p class="postmetadata"><?php the_time('F jS, Y') ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit','',' |'); ?>  <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></p> </div>  <?php endwhile; ?> < ? PHP的,如果( have_posts ( ) ) : ? > < ? PHP的,而( have_posts ( ) ) : the_post ( ) ; ? > <學級= “郵報”編號= “後的< ? PHP的the_id ( ) ; ? > ” > <p class="postmetadata"> < ? PHP的the_time ( ' f js , Y) ? >張貼在< ? PHP的the_category ( ' , ' ) ? > | < ? PHP的edit_post_link ( '編輯','',' | ' ) ; ? > < ? PHP的comments_popup_link ( '沒有評論' , '1評論' , ' %評論' ) ; ? > < / > < /學> < ? PHP的endwhile ; ? > 

“The Loop” in Wordpress is a function that retrieves from your database a series of (10) posts. “河套”在WordPress是一個功能檢索從您的數據庫了一系列的( 10 )的職位。 It starts out with the “have_posts” line and ends with the “endwhile” line.它開始與“ have_posts ”路線,並結束與“ endwhile ”路線。 It’s called the loop because it does the same thing over and over - one post at a time.它的所謂的循環,因為它同樣的事情並超過-一後在一段時間。 That’s why inside “the loop” is the code to print the time, category, comment count, and whatever miscellaneous things are in your themes loop.這就是為什麼內“循環”是該守則,以打印的時間,類別,評論,計數,及雜項的東西,無論是在您的主題循環。 You loop might be slightly different than my example for just that reason, different details are displayed for posts in different themes.您環路可能略有不同,比我的榜樣,只是這個原因,不同的細節顯示的職位在不同的主題。 That’s the beauty of being able to “hack wordpress” - you can easily change those details.這就是美麗的“能哈克的WordPress ” -您可以輕易地變更這些細節。

What we’re going to do is insert a “counter” in the loop, and then tell it to do something when it reaches certain numbers in the count.我們正在做的是插入一個“反”的循環,然後告訴它做一些事情,當它達到一定的數目,在計數。 Here’s the modified code to do that:這裡的修改過的代碼這樣做:

 <?php if (have_posts()) : ?> <?php $count = 1 ?>  <?php while (have_posts()) : the_post(); ?>      <div class="post" id="post-<?php the_ID(); ?>"> <p class="postmetadata"><?php the_time('F jS, Y') ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit','',' |'); ?>  <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></p> </div>     <?php if ($count==2) { include('advert1.php'); } ?> <?php if ($count==6) { include('advert2.php'); } ?> <?php $count = $count + 1; ?>  <?php endwhile; ?> < ? PHP的,如果( have_posts ( ) ) : ? > < ? PHP的元計數= 1 ? > < ? PHP的,而( have_posts ( ) ) : the_post ( ) ; ? > <學級= “郵報”編號= “後的< ? PHP的the_id ( ) ; ? > “ > <p class="postmetadata"> < ? PHP的the_time ( ' f js , Y) ? >張貼在< ? PHP的the_category ( ' , ' ) ? > | < ? PHP的edit_post_link ( '編輯','',' | ' ) ; ? > < ? PHP的comments_popup_link ( '沒有評論' , '1評論' , ' %評論' ) ; ? > < / > < /學> < ? PHP的,如果(元計數== 2 ) (包括( ' advert1.php ' ) ; ) ? > < ? PHP的,如果(元計數== 6 ) (包括( ' advert2.php ' ) ; ) ? > < ? PHP的元計數=元計數+ 1 ; ? > < ? PHP的endwhile ; ? > 

You’ll notice in this modified example that on the second line we have inserted a counter that starts with “1″ the first time through.您會發現在這修改,例如,就在第二行,我們已插入一個反開頭為“ 1 ”第一時間通過。 The second to the last line (count + 1) ads one number to the counter each time through so it can keep track of which post we’re on.第二至最後一行(計數+ 1 )廣告一編號,以櫃檯每一次通過,因此可以跟踪,其中郵政我們正在對。 The two lines before that say “if the counter is on #2 or #6 - include this file”.兩行之前說: “如果反是對# 2或# 6 -包括此文件” 。 I created 2 files, both advert1.php and advert2.php and placed them in my theme directory.我創建了2個文件,都advert1.php和advert2.php並置於他們在我的主題目錄。 When the counter reaches 2 or 6 it opens those files and prints the contents to the page.當計數器達到2或6 ,開放這些檔案和打印的內容到該網頁。 For my home page, both those files contain the adsense code to be displayed in those spots.我的首頁,無論是這些文件包含AdSense代碼,以顯示在這些景點。 As I said - you could include anything, and you can name those file whatever you want.正如我剛才所說-您可以加入的話,您可以和這些檔案的名稱,無論你想。 In addition, you can change, modify, or add lines to the counter for any number 1-10 as well.此外,您還可以變更,修改,或添加線反給任何數量,以及1月10日。

3. 3 。 Dump the Next and Previous : I’ve always hated those “previous posts” link on the bottom of every Wordpress homepage. 轉儲下一頁和前 :我總是討厭那些“先前的文章”鏈接,底部的每一個網頁的WordPress 。 I want my visitor’s (especially the first time ones) to know that I have many pages of content they can peruse, and a numbered list (like navigation at google) tells them just that.我希望我的訪客的(尤其是第一次的個案)知道,我有很多頁的內容,他們可以審閱,並編號的清單(如導航在Google )告訴他們這一點。 They can easily jump back to page 3, or 6, or whatever to view previous posts, and then back again.他們可以很容易彈回第3頁,或六,或什麼,以查看以前的帖子,然後再次回。 Wordpress’ pagination feature of only one page at a time is terrible at best. WordPress所'分頁的特點,只有一個頁上的時間是可怕的,在最好的。 The那個 WP Page Numbers Wordpress plugin可濕性粉劑頁碼wordpress插件 takes care of this seamlessly.照顧這無縫。 *Note, this plugin can also be used all other templated pages where more than one page of posts are retrieved. *請注意,此插件也可用於所有其他模板的頁面當不止一個網頁的職位是文字。

4. 4 。 Homepage Excerpts : If you want to control how many posts on your home page are displayed full and how many to show as excerpts (without mucking in any code at all), 網頁摘錄 :如果您想控制多少職位對您的首頁顯示的充分和有多少顯示為摘錄(無碴在任何代碼在所有) , Homepage Excerpts網頁摘錄 is the plugin you need.插件是您所需要的。 I use this on most of my Wordpress sites, and you basically configure it with 1 click (how many posts to display full).我用這個對我的大部分的WordPress網站,你基本上配置它與1單擊(有多少職位,以顯示完整的) 。

5. 5 。 Enable Post Voting : You could enable a voting function by using 使郵政投票 :你可以讓投票功能,通過使用 Vote It Up投票起來 enabling your Wordpress readers to vote for your posts Digg or Reddit style, and then put a list of most popular ones at the top of your homepage like this:使您的WordPress讀者投票,為您的職位digg或reddit樣式,然後提出一個名單,最受歡迎的在頂部的您的首頁是這樣的:

投票它的WordPress的例子

6. 6 。 Random Featured Post : Use your old posts and give them new life, by creating featuring a random post before your content on your home page using the 隨機精選後 :使用您的舊帖子,並給予他們新的生命,創造具有隨機職位之前,您的內容對您的首頁使用 Random Featured Post Wordpress Plugin .隨機精選後的wordpress插件 You might also try 您也可以嘗試 Advanced Random Post 先進的隨機郵政 .

7. 7 。 Display an Accouncement : Using the 顯示accouncement :使用 Genki Announcement元氣壽司公佈 plugin you can display an announcement before your posts on the homepage.插件您可以顯示一宣布後,您的帖子上的網頁。 This is great, because you don’t have to hack any code to do this, you can turn the message on or off whenever you want, and you can even restrict it to differerent roles or users if you need to.這是偉大的,因為你不須開刀的任何代碼,為此,您可以把訊息或關閉時,您想要的,和你甚至可以限制它differerent角色或用戶如果您需要。 There’s even a timer feature to turn the announcement on or off.甚至還有定時器功能,把公佈或關閉。 Your message could be holiday related (Merry Christmas!), or a time advertisement (for 48 hour only), a message (to all site admins), or everyone (thanks for visiting my blog!).您的郵件,可假期有關(聖誕快樂! ) ,或一段時間的廣告( 48小時) ,一個信息(所有的網站管理員) ,或大家(感謝訪問我的博客! ) 。

8. 8 。 Make a Post “Sticky” : Instead of an announcement or a random post, maybe what you want to do is make one particular post “sticky” - or have it stay at the top of the homepage (until you change it). 作出郵報粘” :不是一公佈或隨機後,也許你想要做的就是使某一郵報“粘” -或有它留在頂端的網頁(直到您改變它) 。 Easy enough, Lester Chan’s容易不夠,萊斯特成龍的 Creating a Dynamic Sticky創造一個動態的粘性 “. “ 。 Basically he figured out how to create “two loops” on the homepage.基本上,他揣摩如何製造“兩個循環”上的網頁。 The first loop gets one post from one category.第一迴路獲得一個職位由一類。 Basically he created a new category called “frontpage” and assigned all the articles he wanted to “feature” for a time.基本上,他創造了一種新的類的所謂“ FrontPage中”和分配的所有條款,他希望以“功能”的時間。 Then the first loop shows one featured article at a time in a styled div box.然後第一迴路顯示,一精選的文章在一個時間在一式學方塊。 Then, immediately following the normal loop gets the 10 latest posts from the database, but it does check to ensure that it doesn’t duplicate the featured post again.然後,緊接著的正常循環得到10最新職位從數據庫中,但它確實查核,以確保它不重複精選後的一次。 Very nice hack!很好的哈克!

10. 10 。 Edit Article Excerpts : 編輯文章的摘錄 Wordpress Excerpt Editor WordPress所摘錄編輯器 is a unique plugin that allows you to add custom excerpts for page (something you can’t do without a plugin).是一個獨特的插件,使您可以添加自定義摘錄網頁(你不能做的沒有一個插件) 。 Normally, if you choose to use excerpts - Wordpress will take the first so many words of your posts.一般情況下,如果您選擇使用摘錄-W ordPress所將採取的第一個有這麼多的話,您的職位。 As far as your homepage is concerned, this doesn’t do much for “original content” or avoiding “duplicate content” at all.據您的首頁來說,這並不很多“原始內容”或避免“重複的內容” 。 This plugin enables you write a custom excerpt for each post or page, as you write it.此插件可以讓您寫摘錄自定義為每一個職位或網頁,正如你將它寫。 Then, if you use excerpts on your homepage - the custom excerpt will be dispayed instead of the first “x” words making your home page contain completely unique content.然後,如果您使用的摘錄在您的主頁上-自定義摘錄將d ispayed不是第一次“ X ”的字眼,使您的首頁包含完全獨特的內容。 It also allows you to write some different linkbait enticing people to click and view that article.它也可以讓你寫一些不同的linkbait誘人的人點擊,並認為文章。 It has options to do the same for both archive and tag pages.它選擇這樣做同樣適用於存檔和標記的頁面。

Excerpt Editor also has some advanced options for showing excerpts of “x” recent posts under each Post/Page and it can even show excerpts from “x sub pages” on each page.摘錄編輯器也有一些高級選項顯示摘錄的“ X ”最近的帖子下,每個帖子/頁,它甚至可以顯示摘錄從“ X小組的頁面”在每一頁上。 With all these options, it can do many things beyond custom excerpts on your home page.所有這些選項,它可以做很多事情,超出自訂的摘錄對您的首頁。

11. 11 。 Add Thumbnails to Your Posts Using Custom Fields : There are many, many ways to add images to posts either manually or with a plugin. 添加縮略圖到您的職位,使用自訂的領域 :有很多,很多方法可以添加圖像職位,無論是手動或一個插件。 Once of the most overlooked features of Wordpress is the “custom field”.一旦該國最被忽略的特點WordPress的是“自定義字段” 。 You have the ability to create and fill-in custom fields with every post you write, but probably don’t know it.你有能力創造和填充在自定義字段與每一個崗位你寫,但可能不知道它。 Under every “write post” page is the “custom fields” form (this one from WP 2.5):根據每一個“寫文章”頁是“自定義字段”的形式(此一由可濕性粉劑2.5 ) :

自定義字段的例子

A custom field is nothing more than metadata that you create. 1自定義字段,只不過是比中繼您創建的。 You probably know metadata as keywords and descriptions for search engines, but you can make your own custom metadata fields to describe or enhance your posts.您可能知道元數據關鍵字和說明,搜索引擎,但你可以作出自己的自定義元數據字段來形容,或提高您的職位。 Each custom field has a “key” and then a “value”.每個自訂欄位有一個“鑰匙” ,然後“價值” 。 The key is the name of the metadata (like Image or thumbnail) and the value is the content (like file.gif or picture.jpg).關鍵是名稱的中繼(如圖片或縮略圖)和價值是內容(如file.gif或picture.jpg ) 。 Just Tadlock has a pretty good剛才塔德洛克有一個不錯的 Introduction to Custom Fields介紹了自定義字段 , and also ,也 Custom Fields: Adding Images to Posts自定義字段:新增圖片到職位 .

12. 12 。 Create a Date Button for Posts : Seems like most of the more “premium” Wordpress themes (and hand-crafted ones) have a “date button” for the post, a nice image with the month abbreviation and the date (sometimes the day of the week too). 創建一個日期按鈕職位 :好像大部分的更多的“溢價”的WordPress主題(和手工製作的)有一個日期“按鈕”後,一個好的形象,與一個月的縮寫和日期(有時一天該週太) 。 Small Potato at WP-Designer wrote a great tutorial last year on小土豆在可濕性粉劑設計者寫了偉大的補習社在去年就 How to Create a Date Button如何創建一個日期按鈕 .

I hope these home page hacks helped you, and as always if you have something to add to make this post better (or a question) - please comment now!我希望這些網頁的竅門,幫助你,而且,與往常一樣,如果你有一些補充,使這個職位更好的(或問題) -請評論!


Tags:標籤: , ,

4 Responses to “Wordpress Hack #14: 12 Ways to Hack Your Home Page”四反應“的WordPress哈克# 14 : 12的方式侵入您的首頁”

  1. Paul 保羅 Has the following to say...有下列說...

    I finally understand what the “loop” is.我終於明白何謂“迴路”是。

    I was looking for an easy way to put an introduction-explanation-welcome on one of my sites and the sticky plugin looks like it will work well我一直在尋找一種簡單的方法來付諸表決,介紹了解釋-歡迎對我的一個網站和棘手的插件看來會工作

    Pauls last blog post..1 pauls最後的博客帖子.. 1

  2. Erika 艾莉卡 Has the following to say...有下列說...

    Your “creating a dynamic sticky” link is swallowing some of your code.您的“創造一個動態的粘”鏈接是吞嚥一些您的代碼。 You might be missing a tag in there.您可能失踪的標記在那裡。

    Great post, though.偉大的職位,雖然。 :) : )

    Erikas last blog post..1 erikas最後的博客帖子.. 1

  3. AndrewGribben.com » Blog Archive » links for 2008-05-21 andrewgribben.com »博客存檔»鏈接為2008年5月21日 Has the following to say...有下列說...

    [...] Wordpress Hack #14: 12 Ways to Hack Your Home Page | JTPRATT’s Blogging Mistakes [...] [ … … ]的WordPress哈克# 14 : 12的方式侵入您的首頁| jtpratt的博客失誤[ … … ]

  4. MyZeroWaste myzerowaste Has the following to say...有下列說...

    Thanks very much for these hacks.非常感謝這些駭客。 Just what I wanted to enhnace my blog without resorting to plugins.究竟是什麼我想enhnace我的博客,而不訴諸插件。

    MyZeroWastes last blog post.. myzerowastes最後的博客帖子.. Sunday roundup週日綜述

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!頂端提意見,每一個月中列出的每一頁上這個網站,在工具欄的小裝置相連回到您的網址! 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= (= ; ;= ) ]= ; ; ;