PDA

View Full Version : Button Shortcode For Wordpress



innominds
01-23-2012, 10:35 AM
Actually I was looking to create a wordpress shortcode in Thesis theme.

and found out that this code


function sButton($atts, $content = null) {
extract(shortcode_atts(array('link' => '#'), $atts));
return '<a class="button" href="'.$link.'"><span>' . do_shortcode($content) . '</span></a>';
}
add_shortcode('button', 'sButton');

in custom_functions.php file will result in

Go to Google (by placing anywhere in blog post or page)

Here my query is .... if i want to have another shortcode with rel="nofollow" target="_blank" included in that .....how should I go ahead

wpfox
01-24-2012, 08:06 AM
I guess in the very similar way:

function sLink($atts, $content = null) {
extract(shortcode_atts(array('link' => '#'), $atts));
return '<a href="'.$link.' target='_blank' rel='nofollow'"><span>' . do_shortcode($content) . '</span></a>';
}
add_shortcode('nofolLink', 'sLink');