Twitter

Display a Twitter feed anywhere on your website.

Notes

This feature is available as both a shortcode and sidebar widget.

It has built in cache support, which updates every 15 minutes.

Supports multiple accounts.

Usage

You can display the feed by using the [wpe_twitter] shortcode.

The shortcode also supports the following:

  • [wpe_twitter count="3"] This will display the latest 3 tweets.
  • [wpe_twitter username="twituser"] This is required to pull through the tweets for the specific user.
  • [wpe_twitter order="random"] This will display random tweets.
  • [wpe_twitter class="tweets"] This will give your Twitter <ul> a custom class name.
  • [wpe_twitter search="#keyword"] This will filter your tweets with the hastag keyword you choose.
  • [wpe_twitter media="false"] Hide any media images from your tweets.

Custom Tweet Format

Tweets are displayed in the site inside a <ul>. You can change the format of the tweet by adding the following code to your functions.php file:

function wpe_twitter_format($data) {
    $wpe_twitter_format = '<a href="'.$data['link'].'">'.$data['date'].'</a> '.$data['content'].' by '.$data['author'];
    return $wpe_twitter_format;
}

You can use the following options below to build your custom tweet format:

  • $data['author'] The author’s name.
  • $data['link'] The direct link to the tweet.
  • $data['content'] The tweet content.
  • $data['media'] The image URL of any attached media.
  • $data['date'] The datestamp of the tweet.
  • $data['interact'] The reply/retweet/favourite links.

Post to Twitter

WordPress posts can also be posted as tweets to your Twitter feed.

Simply tick the “Post to Twitter” checkbox under your Publish settings when writing a new post.

If your post has a featured image, it will also be posted to twitter as attached media.

To use this setting, read and write access must be enabled in your Twitter API settings.

Example

[wpe_twitter username="ceefitzpee" count="3" search="#wpessentials"]