Title: Twitter Cards
Author: Niall Kennedy
Published: <strong>2012 年 6 月 17 日</strong>
Last modified: 2013 年 4 月 3 日

---

搜尋外掛

這個外掛**並未在最新的 3 個 WordPress 主要版本上進行測試**。開發者可能不再對這個
外掛進行維護或提供技術支援，並可能會與更新版本的 WordPress 產生使用上的相容性問題。

![](https://s.w.org/plugins/geopattern-icon/twitter-cards.svg)

# Twitter Cards

 由 [Niall Kennedy](https://profiles.wordpress.org/niallkennedy/) 開發

[下載](https://downloads.wordpress.org/plugin/twitter-cards.1.0.5.zip)

 * [詳細資料](https://tw.wordpress.org/plugins/twitter-cards/#description)
 * [使用者評論](https://tw.wordpress.org/plugins/twitter-cards/#reviews)
 * [開發資訊](https://tw.wordpress.org/plugins/twitter-cards/#developers)

 [技術支援](https://wordpress.org/support/plugin/twitter-cards/)

## 外掛說明

Generate inline content previews on Twitter.com and Twitter clients by including
[Twitter Card](https://dev.twitter.com/docs/cards) HTML meta elements for individual
posts.

All cards are a Twitter Card summary by default. Tap into the `twitter_card_properties`
filter to reference the Twitter accounts of your site or author.

Test your site’s Twitter Card display through [Twitter’s card preview tool](https://dev.twitter.com/docs/cards/preview).

### Filters

 * `twitter_cards_properties` – act on an array of properties before they are output
   to the page
 * `twitter_cards_htmlxml` – override the default treatment of `html` with `xml`.
   XML will self-close the meta void element ( “” vs. “” )

## 螢幕擷圖

[⌊Twitter Card display on desktop⌉⌊Twitter Card display on desktop⌉[

Twitter Card display on desktop

[⌊Twitter Card display on mobile⌉⌊Twitter Card display on mobile⌉[

Twitter Card display on mobile

## 常見問題集

  Why don’t you support feature X?

I wrote this plugin for my own site, [NiallKennedy.com](http://www.niallkennedy.com/),
added some slight flexibility through filters, and released the plugin on GitHub
as [a PHP library](https://github.com/niallkennedy/twitter-cards-php) with [a WordPress plugin wrapper](https://github.com/niallkennedy/twitter-cards).
I use summary cards for my site’s articles. If you would like to add better support
for photos, galleries, videos, apps, or products exposed to Twitter you can fork
my work and optionally send some code in a pull request.

 How do I add my Twitter account?

First you need to hook into the filter from code in your theme or site plugin(s).
You can add this code to your theme’s `functions.php` file or create a new file 
in `wp-content/mu-plugins/twitter-cards.php` or something similar.

    ```
    add_filter( 'twitter_cards_properties', 'twitter_custom' );
    ```

Next you need to modify the array passed to the filter with your own values.

    ```
    function twitter_custom( $twitter_card ) {
        if ( is_array( $twitter_card ) ) {
            $twitter_card['creator'] = '@niall';
            $twitter_card['creator:id'] = '1085';
        }
        return $twitter_card;
    }
    ```

The values generated by the plugin are passed to your new function for manipulation
before output.

The Twitter API function users/show is a good way to lookup your account information.
Copy the `screen_name` and `id_str` to `creator` and `creator:id` array values respectively
in your filter function referenced above. https://api.twitter.com/1/users/show.json?
screen_name=niall

Your Twitter screenname may change but your Twitter ID will remain the same. Grab
both while you are setting up your site to provide Twitter with the best data.

 You forgot to include a trailing slash on meta elements

The plugin outputs HTML-style void elements without a trailing slash by default.
Add XML-style trailing slashes by returning a value of `xml` on the `twitter_cards_htmlxml`
filter.

## 使用者評論

這個外掛目前沒有任何使用者評論。

## 參與者及開發者

以下人員參與了開源軟體〈Twitter Cards〉的開發相關工作。

參與者

 *   [ Niall Kennedy ](https://profiles.wordpress.org/niallkennedy/)

[將〈Twitter Cards〉外掛本地化為台灣繁體中文版](https://translate.wordpress.org/projects/wp-plugins/twitter-cards)

### 對開發相關資訊感興趣？

任何人均可[瀏覽程式碼](https://plugins.trac.wordpress.org/browser/twitter-cards/)、
查看 [SVN 存放庫](https://plugins.svn.wordpress.org/twitter-cards/)，或透過 [RSS](https://plugins.trac.wordpress.org/log/twitter-cards/?limit=100&mode=stop_on_copy&format=rss)
訂閱[開發記錄](https://plugins.trac.wordpress.org/log/twitter-cards/)。

## 變更記錄

#### 1.0.5

 * Update Twitter Cards PHP library to support extending the plugin for new app,
   gallery, or product Twitter Card types.

#### 1.0.4

 * Treat post format of “image” as a Twitter photo card.

#### 1.0.3

 * Simplify the description generator. Based on the Open Graph protocol description
   generator in the Facebook plugin.
 * Update bundled version of Twitter Cards PHP, fixing description property treated
   as a required property for photo card type.

#### 1.0.2

 * Change attribute from value to content to match current Twitter documentation.

#### 1.0.1

 * Improve automatic excerpt generator and scrubber

#### 1.0

 * Initial release

## 中繼資料

 *  版本 **1.0.5**
 *  最後更新 **13 年前**
 *  啟用安裝數 **300+**
 *  WordPress 版本需求 ** 3.3 或更新版本 **
 *  已測試相容的 WordPress 版本 **3.5.2**
 *  語言
 * [English (US)](https://wordpress.org/plugins/twitter-cards/)
 * 標籤:
 * [semantic markup](https://tw.wordpress.org/plugins/tags/semantic-markup/)[twitter](https://tw.wordpress.org/plugins/tags/twitter/)
   [twitter cards](https://tw.wordpress.org/plugins/tags/twitter-cards/)
 *  [進階檢視](https://tw.wordpress.org/plugins/twitter-cards/advanced/)

## 評分

 4.5 星，滿分為 5 星

 *  [  1 個 5 星使用者評論     ](https://wordpress.org/support/plugin/twitter-cards/reviews/?filter=5)
 *  [  1 個 4 星使用者評論     ](https://wordpress.org/support/plugin/twitter-cards/reviews/?filter=4)
 *  [  0 個 3 星使用者評論     ](https://wordpress.org/support/plugin/twitter-cards/reviews/?filter=3)
 *  [  0 個 2 星使用者評論     ](https://wordpress.org/support/plugin/twitter-cards/reviews/?filter=2)
 *  [  0 個 1 星使用者評論     ](https://wordpress.org/support/plugin/twitter-cards/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/twitter-cards/reviews/#new-post)

[查看全部使用者評論](https://wordpress.org/support/plugin/twitter-cards/reviews/)

## 參與者

 *   [ Niall Kennedy ](https://profiles.wordpress.org/niallkennedy/)

## 技術支援

使用者可在技術支援論壇提出意見反應或使用問題。

 [檢視技術支援論壇](https://wordpress.org/support/plugin/twitter-cards/)