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.

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

share|improve this question
add comment

1 Answer 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)

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.