I have already added an link in my widget
eg:
<a target="_blank" href="google.com" class="a-button">Learn More</a>
I need an shortcode like this
[button link="google.com" value="Learn More"]
If i paste this shortcode in widget, page and post, link must appear
Style must be same as above tag
Current Code:
function button_shortcode($atts, $content = null) {
extract( shortcode_atts( array( 'url' => '#' ), $atts ) );
return '<a href="'.$url.'" class="a-button">' . do_shortcode($content) . '</a>';
}
add_shortcode('button', 'button_shortcode');
How can i do this ?
Basic shortcode will look like this:
You can read more on shortcode api on: http://codex.wordpress.org/Shortcode_API
In order to make your widget with shortcodes should use do_shortcode( $content ) function inside update method of your widget.
Like this:
Or use a plugin that will make it for default widgets like this https://wordpress.org/plugins/shortcodes-in-sidebar-widgets/
thank you all, i tried out this one
For shortcode support in widget paste below line in functions.php
created shortcode: