Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I wonder if is it possible to have a shortcode inside another one?

My scenario is this:

I create a shortcodes to display content into columns so I can manage the layout of the page more easily. Now the problem comes, when I try to use for sample nextgen gallery into one of those shortcodes. For some reason it just generates the shortcode as plain text.

Any idea why?

I will show you the code I'm using for the shortcode maybe it helps:

 // Column ShortCode Description
function column_scdescription($atts, $content="null") {
    return '<div class="description">' .$content . '</div> <!-- description ends here -->';
}
add_shortcode ("product-description", "column_scdescription");

Thanks in advance.

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

I usually apply the_content filters to $content to do this. I think you can aslo use do_shortcode($content);

// Column ShortCode Description
function column_scdescription($atts, $content="null") {
    return '<div class="description">' .apply_filters('the_content', $content) . '</div> <!-- description ends here -->';
}
add_shortcode ("product-description", "column_scdescription");

Read up on Nested Shortcodes in the codex.

share|improve this answer
    
works like charm! thanks a ton! –  andresmijares25 Dec 1 '11 at 2:12
add comment

'you can use the do_shortcode() wp function

function column_scdescription($atts, $content="null") {
    return '<div class="description">' . do_shortcode($content) . '</div>';
}
add_shortcode ("product-description", "column_scdescription");
share|improve this answer
    
does it work only if inside there is a shortcode right? if there plain text would it work? thanks for answer! –  andresmijares25 Dec 1 '11 at 2:03
1  
if there isn't a shortcode inside it will return as plain text. –  Ijaas Dec 1 '11 at 2:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.