WordPress.org

Ready to get started?Download WordPress

Plugin Directory

Fetch Tweets

Fetches and displays tweets from twitter.com with the Twitter API.

Other Notes

Shortcode and Function Parameters

The following parameters can be used for the shortcode or the PHP function of the plugin, fetchTweets()

  • id - the ID(s) of the rule set. This cannot be used with the tag, q, or screen_name parameter. e.g.
[fetch_tweets id="123"]
<?php fetchTweets( array( 'id' => 123 ) ); ?>

In order to set multiple IDs, pass them with commas as the delimiter. e.g.

[fetch_tweets id="123, 234, 345"]
<?php fetchTweets( array( 'id' => 123, 234, 345 ) ); ?>
  • tag - the tag(s) associated with the rule sets. This cannot be used with the id, q, or screen_name parameter. e.g.
[fetch_tweets tag="WordPress"]
<?php fetchTweets( array( 'tag' => 'WordPress' ) ); ?>

In order to set multiple tags, pass them with commas as the delimiter. e.g.

[fetch_tweets tag="WordPress, developer"]
<?php fetchTweets( array( 'tag' => 'WordPress, developer' ) ); ?>
  • operator - the database query operator that is performed with the tag parameters. Either AND, NOT IN, or IN can be used. If this parameter is not set, AND will be used as the default value. For more information about this operator, refer to the Taxonomy Parameter section of Codex. e.g.
[fetch_tweets tag="WordPress, PHP, JavaScript" operator="IN" ]
<?php fetchTweets( array( 'tag' => 'WordPress, PHP, JavaScript', 'operator' => 'IN' ) ); ?>
[fetch_tweets tag="developer" operator="NOT IN" ]
<?php fetchTweets( array( 'tag' => 'developer', 'operator' => 'NOT IN' ) ); ?>
  • q - the search keyword. This cannot be used with the id, tag, or screen_name parameter. e.g.
[fetch_tweets q="#wordpress" lang="en"]
<?php fetchTweets( array( 'q' => '#wordpress', 'lang' => 'en' ) ); ?>
  • screen_name - the screen name(s). To pass multiple screen names, pass them separated by commas. This cannot be used with the id, tag, or q parameter. e.g.
[fetch_tweets screen_name="WordPress,photomatt"]
<?php fetchTweets( array( 'screen_name' => 'WordPress,photomatt' ) ); ?>
  • count - the maximum number of tweets to display. e.g.
[fetch_tweets id="456, 567" count="10" ]
<?php fetchTweets( array( 'id' => 456, 567, 'count' => 10 ) ); ?>
  • avatar_size - the size( max-width ) of the profile image in pixel. e.g.
[fetch_tweets id="678" count="8" avatar_size="96" ]
<?php fetchTweets( array( 'id' => 678, 'count' => 8, 'avatar_size' => 96 ) ); ?>
  • twitter_media - true (1) / false (0). Determines whether the twitter media elements should be displayed.
  • external_media - true (1)/ false (0). Determines whether the external media links should be replaced with embedded elements.
[fetch_tweets id="678" twitter_media="0" external_media="1" ]
<?php fetchTweets( array( 'id' => 678, twitter_media="0" external_media="1" ) ); ?>

How to Create Own Template

Step 1

Copy the folder named plain or single in the plugin's template folder. Rename the copied folder to something you like.

Step 2

Edit the following files.

  • style.css - defines the template's CSS rules. Also some of the information in the header comment sections will appear in the template listing table.
  • template.php - defines the layout of the tweets. PHP coding skill is required.
  • functions.php ( optional ) - loaded if the template is activated when the plugin starts. If you don't edit this file, do not include it. Be careful not to declare any PHP function or class that is already declared in the original file.
  • settings.php ( optional ) - loaded only in the admin area if the template is activated. If you don't edit this file, do not include it. Be careful not to declare any PHP function or class that is already declared in the original file.

In the style.css file, include the comment area ( with /* */ ) at the top of the file with the following entries.

  • Template Name: - the template name.
  • Author: - your name.
  • Author URI: - your web site url.
  • Description: - a brief description about the template.
  • Version: - the version number of the template.

e.g.

/*
    Template Name: Sample
    Author: Michael Uno
    Author URI: http://en.michaeluno.jp
    Description: A very simple sample template added as a WordPress plugin.
    Version: 1.0.0
*/

Step 3 ( optional )

Include a thumbnail image. Prepare an image with the name screenshot.jpg, screenshot.png, or screenshot.gif, and place the image in the working(copied in step 1) folder.

Step 4

Create a folder named fetch-tweets in the theme folder. If you use, for instance, Twenty Twelve, the location would be .../wp-content/themes/twentytwelve/fetch-tweets/.

Place the working folder( the copied and renamed one in step 1 ) in there. The plugin will automatically detect it and the template will be listed in the Template page of the admin page.

Optionally, a template can be added via a plugin. If you do so, add the template directory with the fetch_tweets_filter_template_directories filter hook.

e.g.

add_filter( 'fetch_tweets_filter_template_directories', 'FetchTweets_AddSampleTemplateDirPath' );
function FetchTweets_AddSampleTemplateDirPath( $arrDirPaths ) {
    
    // Add the template directory to the passed array.
    $arrDirPaths[] = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'sample';
    return $arrDirPaths;
    
}

You can check an example template here.

Requires: 3.3 or higher
Compatible up to: 3.9.2
Last Updated: 2014-5-15
Downloads: 26,068

Ratings

4 stars
4.6 out of 5 stars

Support

2 of 5 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

0,1,0 100,1,1 100,1,1 100,1,1 100,1,1 100,1,1
100,1,1 100,1,1 100,1,1 100,1,1 100,1,1 100,1,1 100,1,1
50,2,1 100,1,1 100,1,1
100,2,2 100,1,1 100,1,1 100,1,1
100,1,1
100,1,1 100,1,1 100,1,1 100,1,1 100,1,1
100,1,1 100,1,1
100,1,1 100,1,1 100,1,1 100,1,1 100,1,1 100,1,1 100,1,1
100,1,1 100,1,1 100,1,1 100,1,1
100,1,1 100,1,1 100,3,3