WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use this in my Functions.php file to format short codes for some jQuery UI tabs, however I also use a short tag to reference my video embeds, which breaks when they're inside the UI tabs.

My question is, how would I just pass my video short code through this function unaltered:

// jQuery UI Tabs
add_shortcode( 'tabgroup', 'etdc_tab_group' );
function etdc_tab_group( $atts, $content ){
$GLOBALS['tab_count'] = 0;

do_shortcode( $content );

if( is_array( $GLOBALS['tabs'] ) ){
foreach( $GLOBALS['tabs'] as $tab ){
$tabs[] = '<li><a class="" href="#'.$tab['title'].'">'.$tab['title'].'</a></li>';
$panes[] = '<div id="'.$tab['title'].'"><h3>'.$tab['title'].'</h3>'.$tab['content'].'</div>';
$return = "\n".'<!-- the tabs --><div id="tabs"><ul>'.implode( "\n", $tabs ).'</ul>'."\n".'<!-- tab "panes" -->'.implode( "\n", $panes ).'</div>'."\n";
return $return;

add_shortcode( 'tab', 'etdc_tab' );
function etdc_tab( $atts, $content ){
'title' => 'Tab %d'
), $atts));

$x = $GLOBALS['tab_count'];
$GLOBALS['tabs'][$x] = array( 'title' => sprintf( $title,   $GLOBALS['tab_count'] ), 'content' =>  $content );

My video short code looks like this [video src="http://site.com/uploads/example.mp4"]. I imagine I just have to set something in $GLOBALS, but I don't know how I would just pass it through unaltered.

(My 'video' short code is being translated by another plugin)

Update: This was the solution to my problem. Adding do_shortcode to $panes:

$panes[] = '<div id="'.$tab['title'].'"><h3>'.$tab['title'].'</h3>'.do_shortcode($tab['content']).'</div>';
share|improve this question
try adding do_shortcode( $content ); to etdc_tab function – Bainternet Feb 28 '11 at 15:55
@Bainternet Moving the do_shortcode($content); to the etdc_tab function, doesn't solve it. – PHearst Mar 1 '11 at 12:57

Here's a trick that wp-includes/media.php uses for the embed shortcode: first remove all shortcodes, then add a specific shortcode back to the system, filter your content for it, then re-register the original shortcodes.

Try this:

function etdc_tab_group( $atts, $content ){
  global $shortcode_tags;
  $GLOBALS['tab_count'] = 0;

  // save the shortcode registrations
  $orig_shortcode_tags = $shortcode_tags;
  // remove them all
  // add ours back in
  add_shortcode( 'tab', 'etdc_tab' );
  $content = do_shortcode( $content );
  // restore original shortcodes
  $shortcode_tags = $orig_shortcode_tags;

  //...rest of the function...

Actually, now that I'm looking at that etdc_tab_group() function more closely, I'm suprised it's not breaking something... Did you copy and paste it directly, or did you edit anything out? Because it's never passing $content back out again.

So first thing I'd try is just commenting out the do_shortcode() call and see how that works. If that breaks something else, then try the method above?

share|improve this answer

Your Answer


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.