Create wordpress shortcode for jQuery UI Tabs Create wordpress shortcode for jQuery UI Tabs wordpress wordpress

Create wordpress shortcode for jQuery UI Tabs


OK this is what you have to do.

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


You can also add shortcode like this:-

// Tabfunction tab_shortcode( $atts, $content = null ) {    extract( shortcode_atts( array(        'title' => ''    ), $atts ) );    return '<div id="tabs-'. sanitize_title( $title ) .'">'. do_shortcode( $content ) .'</div>';}add_shortcode( 'tab', 'tab_shortcode' );// Tabs Containerfunction tabs_container_shortcode( $atts, $content = null ) {    preg_match_all( '/tab title="([^\"]+)"/i', $content, $matche, PREG_OFFSET_CAPTURE );    $tab_title = array();    if( isset($matche[1]) ) {        $tab_title = $matche[1];    }    $output = '';    if( count($tab_title) ) {        $output .= '<div id="tabs">';        $output .= '<ul class="nav clearfix">';        foreach( $tab_title as $tab ){            $output .= '<li><a href="#tabs-'. sanitize_title( $tab[0] ) .'">' . $tab[0] . '</a></li>';        }        $output .= '</ul>' . do_shortcode( $content ) . '</div>';    } else {        $output .= do_shortcode( $content );    }    return $output;}add_shortcode( 'tabs_container', 'tabs_container_shortcode' );

This will also work for tabs. Hope this will help you bit.