I've built a super-crazy Wordpress framework that has a million and one shortcodes, one of those is a columns shortcode which supports a count parameter that allows you to define a column and the appropriate class will be added.
My shortcode is as follows:
add_shortcode('column', 'column_shortcode');
function column_shortcode($atts, $content = '')
{
extract(shortcode_atts(array(
'count' => 12
), $atts));
if (stripos($count, '_') === FALSE)
{
if ((int) $count > 12)
{
$count = 12;
}
}
$html = '<div class="column-'.$count.' column">';
$html .= do_shortcode($content);
$html .= '</div>';
return $html;
}
There appears to be an issue however when the column shortcode is used within a column, is this a known issue or does Wordpress not support shortcodes of the same name being nested within one another?
What essentially happens is the column inside is prematurely closed off in the outputted HTML and I see [/column] wrapped in paragraph tags being shown on the front-end. However if I create another shortcode and call it child, using the exact same code as above only the child shrotcode is just [child] instead of [column] everything works as expected.
Here is the code from the WYSIWYG editor in my Wordpress installation. Exhibit A is the ideal scenario, I don't want to have to use two different shortcodes that do the same thing. Exhibit B is what works by simply duplicating the shortcode.
Exhibit A - does not work
[column count="9"]
[column count="8_9"]
Welcome to the site.
Who's brave enough to fly into something we all keep calling a death sphere? Well, then good news! It's a suppository. A true inspiration for the children. Ah, computer dating. It's like pimping, but you rarely have to use the phrase "upside your head."
[/column]
[/column]
Exhibit B - works
[column count="9"]
[child count="8_9"]
Welcome to the site.
Who's brave enough to fly into something we all keep calling a death sphere? Well, then good news! It's a suppository. A true inspiration for the children. Ah, computer dating. It's like pimping, but you rarely have to use the phrase "upside your head."
[/child]
[/column]