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 asked this elsewhere but I'm not getting very far with the answers, so thought I'd try here as it's specific to Wordpress. I have this shortcode:

function reytab($atts, $content = null) {
    extract(shortcode_atts(array('title' => '#'), $atts));
    return '<div class="tab">'.
        '<h2 class="reytab">'.
            $title.
        '</h2>'.
        '<div class="tab-content">'.
            do_shortcode($content).
        '</div>'.
    '</div><!-- End div.tab -->';
}
add_shortcode('reytab', 'reytab');

And I'm calling it in my wysiwyg editor in Wordpress like this:

Shortcode in wysiwyg editor

This is the markup that's generated from my shortcode and as you can see the $content is being rendered outside of the .tab-content div:

<div class="tab">
    <h2 class="reytab">Title</h2>
    <div class="tab-content"></div>
</div>
...content appears here...[\reytab]

You can see that [/reytab] is being rendered as part of the $content, so I'm assuming my issue is something to do with either the shortcode, a conflict with a plugin (which it's not as I've deactivated all of them to test that) or a conflict in my theme (which I'm also assuming it's not as I tried this with TwentyEleven - although, as I'm using a child theme that relies on TwentyEleven, it's still possible it's a conflict I guess).

Can anyone offer some advice on what I can try? I'm really lost as to what I can check.

Thanks

Osu

share|improve this question
3  
What happens if you change [\reytab] to [/reytab]? I think your slash is just backwards and things are trying to compensate for the mismatched elements caused by that. –  m0r7if3r Feb 29 '12 at 19:54
    
@m0r7if3r You are amazing. I can't believe it was that simple, I feel like such a d**k. Please provide this as your answer and I'll credit you with solving my problem. –  Osu Feb 29 '12 at 20:21
    
Hah, we all have those days. Solution submitted. –  m0r7if3r Feb 29 '12 at 20:39
add comment

1 Answer

up vote 2 down vote accepted

Your code is fine, the issue is in your shortcode. If you look around line 200 of /wp-includes/shortcodes.php, you can see that only / is supported for the close tag, not \. If you change [\reytab] to [/reytab] it will work!

share|improve this answer
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.