Skip to content

Instantly share code, notes, and snippets.

@artboard-studio
Created October 5, 2013 14:18
Show Gist options
  • Save artboard-studio/e87233dda8dc1582d1da to your computer and use it in GitHub Desktop.
Save artboard-studio/e87233dda8dc1582d1da to your computer and use it in GitHub Desktop.
Twitter Feed Shortcode
function mb_twitter($atts, $content = null ){
extract(shortcode_atts(array('count'=>'3','user'=>''), $atts));
//Cache user and then return last tweeted items (3 by default)
$via = '<div class="tweet-via"><a href="https://twitter.com/intent/user?screen_name='.$user.'" target="_blank" rel="nofollow">@'.$user.'</a></div>';
return '<div class="twitter-feed"><ul id="twitter_update_list"><li>Twitter feed loading</li></ul>'.$via.'</div><script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
<script type="text/javascript" src="https://api.twitter.com/1/statuses/user_timeline.json?screen_name='.$user.'&amp;callback=twitterCallback2&amp;count='.$count.'"></script>';
}
add_shortcode('mb_twitter', 'mb_twitter');
// use this shortcode [mb_tweets count=5 user="OnlineMarket"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment