Skip to content

Instantly share code, notes, and snippets.

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

Embed
What would you like to do?
WordPress: Custom shortcode
<?php
/*
Plugin Name: Twitter Shower
Plugin URI: http://vienhoang.com
Description: Display message.
Version: 1.0
Author: Vien Hoang
Author URI: http://vienhoang.com
License: GPL2
*/
// $content is between the shortcode
add_shortcode( 'twitter', function( $atts, $content ) {
$atts = shortcode_atts(
array(
'username' => 'vienhoang',
'content' => !empty($content) ? $conent : 'Follow me on Twitter!'
), $atts
);
// Extact the atts array and get variables from keys
extract($atts);
return "<a href=\"http://twitter.com/{$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.