Creating a shortcode in Wordpress
- سُلَيْمَان بْن دَاوُوْد

- Aug 28, 2020
- 1 min read
Creating a short code in word press can be handy at times
Assume following code from functions.php
function add_content_buttons($atts){
$atts = shortcode_atts(
array(
'text' => '',
'url' => '',
'color'=> '#000'
), $atts, 'bartag' );
return '<a style="color:'.$atts['color'].'" class="postcardstarthere btn build-list" href="'.$atts['url'].'">'.$atts['text'].'</a>';
}
add_shortcode('content_buttons','add_content_buttons' );The short code in back end look like

The Display in front end Looks Like

The code in active theme's functions.php looks like

Comments