Creating custom shortcodes codes in Wordpress
If you need some custom shortcodes, you have to add a few lines in your themes function.php file.
First, create the function that you want to use. In this example well just make the text red between [red][/red].
function makeRed($atts, $string) {
return <span style="color: #ff0000;">.$string.</span>;
};
Next we need to register our function.
function register_shortcodes() {
add_shortcode(red, makeRed);
};
Finally, we need to make the whole thing work.
add_action(init, register_shortcodes);
alternative link download