0

I have a theme where the wysiwyg button to insert the shortcodes is not appearing. I am trying to manually type in the shortcode that would output the tabs that I need. I am looking at the function that generates the shortcode to try deduce what that might be. The function is

    function display_tabs(){

    var code        = '[tabs ';
    var tab_names   = '';
    var tabs        = '';
    var tab_index   = 0;

    $('.shortcode-dynamic-items').each( function(){

        $(this).children('.shortcode-dynamic-item').each( function(){

            tab_index++;

            tabs += '[tab id=' + tab_index + ']';

            //input loop for extra attrs
            $(this).children('#options-group').find('.attr').each( function(){

                if( $(this).attr('data-attrname') == 'tab_name' ){

                    tab_names += 'tab' + tab_index + '="' + $(this).val() + '" ';
                }

            });

            // if the shortcode has content
            if( $(this).find('#shortcode-content').length > 0 ){

                tabs += $(this).find('#shortcode_content').val();

            }

            tabs += '[/tab]';

        })
    });

    code += tab_names + ']' + tabs + '[/tabs]';

    return code;
}

I have tried a few attempts and have the tabs showing on the page but the content of the tabs is not showing and not toggling between them

[tabs 1 2 3]
[tab]Content for tab one goes here.[/tab]
[tab]Content for tab two goes here.[/tab]
[tab]Content for tab three goes here.[/tab]
[/tabs]

Is it possible to work out exactly what it should be from the function?

0

I wonder if this would work:

[tabs tab1="Tab 1" tab2="Tab 2" tab3="Tab 3"]
    [tab id="1"]Content for tab one goes here.[/tab]
    [tab id="2"]]Content for tab two goes here.[/tab]
    [tab id="3"]]Content for tab three goes here.[/tab]
[/tabs]

You should also check if the shortcode definitions exists:

add_shortcode( 'tabs', 'some_function_for_tabs' );
add_shortcode( 'tab',  'some_function_for_tab' );
  • 1
    Great that worked! and the shortcode definition does exist. Cheers – Ciarán May 25 '14 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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