Skip to content

Instantly share code, notes, and snippets.

@vienhoang vienhoang/index.php
Created Aug 11, 2014

What would you like to do?
WordPress: Custom shortcode
Plugin Name: Twitter Shower
Plugin URI:
Description: Display message.
Version: 1.0
Author: Vien Hoang
Author URI:
License: GPL2
// $content is between the shortcode
add_shortcode( 'twitter', function( $atts, $content ) {
$atts = shortcode_atts(
'username' => 'vienhoang',
'content' => !empty($content) ? $conent : 'Follow me on Twitter!'
), $atts
// Extact the atts array and get variables from keys
return "<a href=\"{$username}\">{$content}</a>";
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.