shortcode
-
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 codefunction 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 = "https://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.