為你的網誌加入Facebook推文按鈕(Like Button)

Facebook Like Button(說讚按鈕,在這裡以推文按鈕代稱)能夠讓你的網誌讀者快速分享內容給他們在Facebook上的朋友。為網誌加入Facebook推文按鈕很簡單,只需要複製以下的原始碼,並貼到你網誌合適的區塊。

推文按鈕必須新增到每篇文章、或是每個頁面,才能發揮功能。如果你使用 WordPress 架站,只需要開啟佈景主題裡的 single.php 檔案,並將以下原始碼貼在適當的位置。

<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink());?>&layout=standard&show_faces=true&width=450&height=60&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none;overflow:hidden;width:450px;height:60px"></iframe>

對了,你也可以適當調整 iframe 的長度及寬度來符合網誌本身的樣式。

如果你使用簡單的Blogger範本,將以下原始碼複製並貼上於HTML:

<iframe src="http://www.facebook.com/plugins/like.php?href=<$BlogItemPermalinkUrl$>&layout=standard&show-faces=true&width=450&height=60&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none;overflow:hidden;width:450px;height:60px"></iframe>

新式的Blogger範本可以試著使用下面的原始碼。

<iframe src="http://www.facebook.com/plugins/like.php?href=data:post.url&layout=standard&show-faces=true&width=450&height=60&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none;overflow:hidden;width:450px;height:60px"></iframe>

注意:你必須編輯Blogger範本的HTML,並將上方的原始碼貼在推文按鈕出現的位置 試著搜尋 <b:includable id=’post’ var=’post’>。

由於內嵌網頁是儲存於Facebook,該按鈕能顯示個人化的訊息。對於已登入Facebook的使用者,按鈕會顯示哪些朋友也喜歡這篇文章,也會同時出現在個人頁面的活動裡。

This entry was posted in WordPress技巧. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

2 Responses to 為你的網誌加入Facebook推文按鈕(Like Button)

  1. Pingback: 【Blog】在單篇網址加入讚跟retweet按鈕 | Robbin.cc

  2. Pingback: 不吃魚的虎斑貓 » Blog Archive » 為你的網誌加入Facebook推文按鈕(Like Button)

發表迴響

您的電子郵件位址並不會被公開。 必要欄位標記為 *

*

您可以使用這些 HTML 標籤與屬性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>