More Related Content Similar to Creating a button shortcode (20) More from Lauren Pittenger (15) Creating a button shortcode1. Creating a Button Shortcode
@laurenpittenger
Slides:
bit.ly/burbswpbuttonshortcode
6. Shortcode Approach
● Shortcode allows the user to create a button
without knowing how to code
● It can be placed anywhere in the content of a
post or page as well as in text widgets
7. function mytheme_button ($atts, $content = null) {
$atts = shortcode_atts( array('link' => '', 'color' => ''), $atts);
return '<a class="button ' . $color . '" href="' . $link . '">' .
do_shortcode($content) . '</a>';
}
add_shortcode( 'button', 'mytheme_button' );
The Code
Get the code on GitHub: bit.ly/buttonshortcode
[button link='http://linktosomething.com' color='orange']My Button Text![/button]