PHP – WordPress – Follow me on Twitter Short Code

This following PHP example helps you to add a short code in to your WordPress post, there's a 
person can follow you on twitter.

Eg. [twitter username='phpmoot']Follow me on Twitter[/twitter]

Code Example:

add_shortcode('twitter', 'twitter_func');
function twitter_func($atts,$content){
	if( !isset($atts['username'])) $atts['username'] = 'phpmoot';
	if( empty($content)) $content = 'Follow me on Twitter';
	return '<a href="' .$atts['username'].'">' .$content.'</a>';

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

Leave a Comment

Your email address will not be published. Required fields are marked *