Something to watch for on WordPress shortcodes - Digital Tool Factory blog Something to watch for on WordPress shortcodes - Digital Tool Factory blog

Something to watch for on WordPress shortcodes

The first inclination is to create a shortcode that will look like [MyShortCode]My Only Parameter[/MyShortCode], which would look like this

function MyShortCode_func($content = null){
//————-stuff happens
return $processedContent;
}

However, if you want to have parameters = you must have the $atts parameter in the function, even if it is not used.  The proper function would be

function MyShortCode_func($atts, $content = null){
//————-stuff happens
return $processedContent;
}

 

Written By Steve French

 

Leave a Reply

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






Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.