Just a simple twitter/identica shortcode

I realized that I will likely reference many twitter people in posts and I think it is common courtesy to link to their profile so that you can go check them out if you want. However, I also want to be lazy and not have to type out their full twitter url all the time. Thus I decided that a shortcode would be nice and efficient.

With the following code,

[code type=”php”]
‘ . $content . ‘‘;
}
add_shortcode(‘twitter’, ‘twitter_shortcode’);
?>
[/code]

I can wrap a username in [twitter] [/twitter] and have it output the full link, like this You forgot a username for the Twitter shortcode

Edit

I have since realized that this is perfectly capable of working with identi.ca as well. For wordpress users of Identi.ca, copy/paste the following code into your functions.php file. It will work the exact same way regarding wrapping the user ID

[code type=”php”]
‘ . $content . ‘‘;
}
add_shortcode(‘identica’, ‘identica_shortcode’);
?>
[/code]

Like so: [identica]tw2113[/identica]

2 thoughts on “Just a simple twitter/identica shortcode

    1. thank you for the kind words Angie. Glad the shortcode will prove useful despite being so basic. Now to come up with more that solve regular problems.

Leave a Reply

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