Title: shortcode
Last modified: August 19, 2016

---

# shortcode

 *  [Niraj Chauhan](https://wordpress.org/support/users/nirajmchauhan/)
 * (@nirajmchauhan)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/shortcode-1/)
 * hii everyone, i have a function of twitter, where when i write this code in my
   single.php or any other file, then it displays the tweets over there,
    `<?php
   the_twitter_feed('userID'); ?>` but i want to use shortcode for this so that 
   i can give it inside my post when i tried the shortcode its returning me an array,
   here is the code
 *     ```
       function the_twitter_feed($username) {
   
           // $username = "Mba_"; // Your twitter username.
           $limit = "5"; // Number of tweets to fetch.
   
           /* These prefixes and suffixes will display before and after the entire block of tweets. */
           $prefix = ""; // Prefix - some text you want displayed before all your tweets.
           $suffix = ""; // Suffix - some text you want displayed after all your tweets.
           $tweetprefix = "<b>" . $username . ": </b> "; // Tweet Prefix - some text you want displayed before each tweet.
           $tweetsuffix = "<br>"; // Tweet Suffix - some text you want displayed after each tweet.
   
           $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=" .
               $limit;
   
           $twitterFeed = get_transient($feed);
           if (!$twitterFeed) {
               $twitterFeed = wp_remote_fopen($feed);
               set_transient($feed, $twitterFeed, 3600); // cache for an hour
           }
           if ($twitterFeed)
               return parse_twitter_feed($twitterFeed, $prefix, $tweetprefix, $tweetsuffix, $suffix);
       }
       add_shortcode('tweet','the_twitter_feed');
       ```
   

The topic ‘shortcode’ is closed to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [Short Code](https://wordpress.org/support/topic-tag/short-code/)

 * 0 replies
 * 1 participant
 * Last reply from: [Niraj Chauhan](https://wordpress.org/support/users/nirajmchauhan/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/shortcode-1/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
