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

    24 Comments to WP List Tweets

    • JohannesPeris says:

      Hey,
      the download links are wrong!

    • Ralf says:

      Hi,

      that is exactly what I am looking for but also for protected accounts.
      Any Ideas?

      Greetings from Hamburg,
      Ralf

    • xD

      Nice Code. Good to setting up.

      Now my last tweet stands under my bloglogo.

      *HAPPY*

    • muriel says:

      how exactly do i add this line of code you’re saying above, and where to add it, if i want to use this plugin as a widget? i’m using the P2 theme.

      thank you.

    • Michael Pehl says:

      Hey.
      First of all, nice plugin.
      Secondly… it does not work for me. Shows only _____ once.

      That’s all. I have inserted it in my footer.php in a sliding panel (right top of my website is the trigger).

      What can i do to fix it? In the admin panel it shows the latest tweets from me correctly.

      Best regards,

      Michael

    • Florian says:

      Great Plugin. Exactly what I was looking for to include multiple tweets of different users. But what about hashtags like e.g. #Test ? They do not link like they do alex kings twitter tools. Could I get this to work too?

    • CREMSNIT says:

      Hello, i like this plugin very much and i want to use it, but i have a problem. When i enter on your site i see your tweets, simple and working! But! when somebody enter to my site appears a window with user+pass from twitter to log in, i don’t want like this. i want like you, when somebody enter on my site to see directly my latest tweets, no windows, no questions..i don’t know where is the problem. i`ve put in settings – wp list tweets – user default and update, but nothing, appear my tweets, but is that problem! when somebody enter, the log in appear… please help me!

      • Marty says:

        I saw the login and thought it must be part of your site.

        The problem is your tweets are protected, so it will only reveal them to your followers, so Twitter is asking people to login.

        Nothing to do with the plugin, just make your Twitter updates public.

        I imagine this same issue would happen with any Twitter plugin.

    • Darren Alawi says:

      Hi Marty,

      Great work. I want to separate each tweet and have them appear in between my post excerpts on my archive.php page, so in between each post excerpt it shows my tweets going back in time. Is this possible, not been able to find a solution.

      Darren.

      • Marty says:

        Thanks, Darren!
        Interesting idea. I’m not sure how to approach that but it is just a matter of numbers so it would definitely be possible. Somehow. Probably a plugin of its own.

    • Sander says:

      Hi Marty,

      great plugin! Exactly what I was looking for and easy to use. Question, is it possible to have a date beneath the tweet instead of a ’53 days ago’?

      Greetings, Sander.

      • marty says:

        Hey Sander,

        Thanks. But this is a pretty specific, simple little plugin. I just wanted an easy way to display the latest from twitter. That’s the way they send it so there’s not much I can (or want to) do about it. I might like a couple options like that too at some point – but won’t have the time to do anything like that any time soon.

        Thanks again!

        Marty

    Trackbacks/Pingbacks

    I'm attending WordCampLA!