WP List Tweets

Thursday, January 14th, 2010 9:46 pm

What is it?

‘Wp List Tweets’ is a free plugin for WordPress that allows you to easily add the latest Tweets from any user, anywhere in your WordPress site.

An Example

    Features

    • Use as many times as you want on each page, even within the same post.
    • Display as many different users as you want (one each time you use it).
    • Control the number of Tweets.
    • Add custom styling.

    Installation and Activation

    Get The File:

    • Navigate to ‘Plugins->Add New’ and use the Plugin Browser to search for ‘WP List Tweets’ right from your site’s admin section and ignore the rest of this section. Or…
    • Download the file here: Download From WordPress Page
    • unzip wp-list-tweets.zip
    • upload the file wp-list-tweets.php to your ‘/wp-content/plugins/’ folder.
    • Navigate to the ‘Plugins’ menu in the admin section.
    • Look for ‘WP List Tweets’ and activate it.

    Activate and Add username:

    • Navigate to ‘Settings->WP List Tweets’.
    • Add the Twitter username you want to use as a default

    How To Use it In a Page or Post or Widget

    • Within a post or page, you can use the shortcode to add it anywhere you want.
    • shortcodes are used by typing the code between brackets like this: [shortcode]
    • [wp_list_tweets]

      Will dsiplay the last 3 Tweets from the default user as set in the plugin’s options. If you have not set a default user, it will display the latest 3 from me. (Someone had to be the default…)

    • [wp_list_tweets user="username"]

      Will dsiplay the last 3 Tweets from ‘username’.

    • [wp_list_tweets user="username" num="5"]

      Will display the last 5 Tweets from from ‘username’.

    • Normally WordPress will not take shortcodes within your widgets. However by adding one line of code, you can make this possible. I have added this line into this plugin, but if you want to make this options available anytime, you can also add the following to your theme’s ‘functions.php’ file
    • add_filter('widget_text', 'do_shortcode');

    How To Use it In Your Theme Files

    • Within a theme file, you use the template tagwith the same variables available:
      • <?php wp_list_tweets(); ?>
      • <?php wp_list_tweets('username'); ?>
      • <?php wp_list_tweets('username','5'); ?>

    Customizing the Look

    The Tweets are displayed in an unordered list. The HTML will be a <ul> element wrapping a series of <li> elements (one for each tweet). Like this:

    <ul id="twitterList-username-1" class="twitterList username">
    <li>TWEET #1 WILL GO HERE</li>
    <li>TWEET #2 WILL GO HERE</li>
    <li>TWEET #3 WILL GO HERE</li>
    </ul>
    

    The plugin adds some default styling which is easily to override. To add custom style to all Tweet lists, Just add the following to your theme’s style.css:

    ul.twitterList  {}
    ul.twitterList li  {}
    

    You can also target each use separately, nice for multi-author sites:

    ul.username {}
    ul.username li  {}
    

    The id uses ‘twitterList’ followed by whatever the username is, follwed by a running number of the times the plugin was used on that particular page. That way you can target any one of them specifically. For the plugin to work, each instance needs a unique ID anyway, so whether or not you use it for the style, the unique ID is still needed.

    Advanced Use

    There is one more variable that can be added to the template tag or to the shortcode. If you want to specifically style any one instance of the plugin, you can add an extra phrase to the ID of the <ul> wrapper, which will replace the running count number at the end. Instead of  – <ul id=”twitterList-username-2″> – , where the number is somewhat arbitrary and likely to change if you add other instances, you could make it  – <ul id=”twitterList-username-myCustomID”>.

    To add ‘MyCustomID’ to the ID of the <ul> wrapper, the template tag would look like this:

    <?php wp_list_tweets('username','5', 'MyCustomID); ?>

    The shortcode would look like this:

    [wp_list_tweets user="username" num="5" id="MyCustomID"]

    Future of the Plugin

    I’m not sure how much more I will put into it, but one idea I had was to add the option to select some colors from the options page in the backend for users unfamiliar with CSS.

    Feedback and Support

    Any feedback is welcome but I can’t promise any real support. I developed this in my spare time and am simply offering it up as-is. I would definitely be interested in hearing about any bugs or ideas for improvement, though so feel free to leave any comments below.

    Share/Bookmark

    17 Comments to WP List Tweets

    Trackbacks/Pingbacks

    Additional comments powered by BackType