WordPress Twitter Tweets Plugin

A simple WordPress plugin to provide integration with the Twitter API 1.1. The plugin provides theme functions and a widget to render tweets from a particular timeline feed using version 1.1 of the Twitter API.

The plugin works by making an API request to Twitter for all available tweets in a particular Twitter timeline feed. The results are then cached using the WordPress transients API and displayed to the user via a theme function or using a widget. The plugin is highly configurable and provides both design and development flexibility.

To display a tweet there are 2 main options:

Theme Function

$ITEM_TO_DISPLAY = 102;
$vars = array(
    "item_number"=>$ITEM_TO_DISPLAY,
    "display_count"=>1,
    "wrapper"=>false,
    "hashtag"=>"ExampleHashTag",
    "referrer"=>"_index",
    "enable_cache"=>true,
    "cache_expiry"=>0,
);
do_action('wp_twitter_tweets_get_tweet',$vars);

The above example will display item number 102 with the hash tag of ExampleHashTag. See below for more information about the specific settings.

Widget

Using the provided widget will allow for similar functionality to the theme function, you can display a specific tweet from the cached array of tweets or simply display a list of tweets.

Default settings

$defaults = array(
    "item_number"=>false,
    "display_count"=>10,        
    "wrapper"=>false,
    "hashtag"=>false,
    "referrer"=>"_theme",
    "enable_cache"=>false,
    "cache_expiry"=>60,
);

  • item_number: The item to display. If left blank the plugin will assume you want to show more then one item
  • display_count: How many items you want to display.
  • wrapper: A HTML wrapper element. If left blank the raw tweet text will be returned.
  • hashtag: Provide a hash tag to display tweets matching the hash tag.
  • referrer: Provide a referred to help with cache management. This is useful if you have lots of theme functions on a page and would like to bust the transient cache for a specific item.
  • enable_cache: Enable the transient cache.
  • cache_expiry: The number of minutes a tweet or list of tweets should be cached for.

Installation

  1. Download and install the plugin and then visit the plugin settings page.
  2. Visit the Twitter developer site to get an API key for your website or app: https://dev.twitter.com/
  3. Copy and paste the relevant info into the plugin settings and save.
  4. Test the plugin is working by creating a new widget or using the theme function.

Download now!

To download this plugin simply tweet about it or post a link on your social media account.

I really appreciate your tweets and links - they help to keep this plugin free!