1

We've started using the Post UI Tabs pluggin but would like to be able to arbitrarily set the tab that is active when the page is loaded. For instance, in one example, we have a three-week process, each week being it's own tab and a fourth tab for resource information, and would like to default the week 3 tab to be active.

Thanks, Tony

1 Answer 1

1

When using Post UI tabs plugin its a bit tricky to set the default tab but not that hard, you need to create your own JavaScript file and put it in your themes folder , lets say you call it custom_script.js inside it add:

jQuery(document).ready(function($){
   $("#tabs-1").tabs("select",  - 2);
});

this is assuming that you don't have more then one set of tabs on that post/page. then add this snippet to your themes functions.php file:

add_action('wp_enqueue_scripts','my_tabs_script');
function my_tabs_script(){
    if (is_page('SLUG')){
        wp_register_script( 'my_tabs', get_bloginfo('template_directory') . '/custom_script.js',array('jquery','post-ui-tabs'), '1.0' ,true);
        wp_enqueue_script( 'my_tabs' );
    }
}

this will only load your newly created script on a page with the slug of SLUG you can use it on posts by changing is_page('SLUG') to is_single(''SLUG_OR_ID)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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