Creating a short-code in WordPress

Creating a short-code in WordPress

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 ''.$atts['text'].'';
}

add_shortcode('content_buttons','add_content_buttons' );

The short code in back end look like

screen83

screen85

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

screen86

Leave a Reply

Your email address will not be published. Required fields are marked *