Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m
  1. Code
  2. Plugins

Creating a Simple Twitter Plugin for WordPress


Let's see how can we make a very simple plugin showing some latest posts from a Twitter account.

Step 1 Download Scripts

Before we begin to write our plugin, we need some JavaScript code.

Step 2 Create File Structure and Copy Files

Create this directory: /wp-content/plugins/tweetfeed-light, and then copy these files.

Step 3 Basic Plugin Data

Continue with creating tweetfeed-light.php (our main plugin file name) with the given content below.

Step 4 The Plugin Class

The basic declaration of our plugin class.

Step 5 Constructor Function

It is a good idea to put the initial settings and requirements into this function. In this section we set the following:

  • plugin path
  • shortcode
  • importing scripts
  • importing styles

The code for these tasks:

Step 6 Retrieving Tweets

Get the latest tweets from a user. We can also set the limit variable controlling the number of tweets.

Step 7 Shortcode Function

This is the helper script for using the plugin with a shortcode.

Step 8 Instantiate Class

Make an object from the plugin class.

Step 9 Final Code

Here is how the code looks when it is finished.

Step 10 Shortcode Usage

To use this plugin you can write the [tweetfeed-light user="johnb" limit="10"] shortcode into the page source you want. For example:

Step 11 The Look

Here is how the plugin looks in the default WordPress theme inserted into a page object.

The look


As you can see this is a simple, but great solution for our mini Twitter mission. For further (color) tweaking you should look into the included stylesheet. Thanks to Icontexto for the Twitter picture!

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.