Create wordpress short codes

Aug 13

When you are creating content for your website, its always requires to repeat some code of html or CSS. If you write down same code in code editor then it might happen that you makes mistake and also managing it becomes bit tough.

You can create short code for doing so.

lets start :-

1. open your function file. Now I have created a sample code for you.

A short code named buzznxButton and its binded with with fn_buzznxButton function. so whenever you will call shortcode buzznxButton it will create a button for you.

function fn_buzznxButton($atts, $content = null) {
extract(shortcode_atts(array('link' => '#'), $atts));
return '<a href="'.$link.'"><span>' . do_shortcode($content) . '</span></a>';
}
add_shortcode('buzznxButton', 'fn_buzznxButton');
for creating a button you will be suppose to write code in this way
[buzznxButton link="http://google.com"] Rapidop Rising [/buzznxButton]
it will create link looking like a button for you. now every time you need same kind of button link just call short code.
sample css code is also writen here
.buzznxButton span{
    background-color:#906;
    color:white;
    padding:10px;
    font-weight:bold;
}

Related Posts:

Leave a Reply