-1

I'm working on a WooCommerce addon/plugin and created a custom admin sub page under WooCommerce menu in dashboard.

Now I am looking to add tabs and sub navigation as per the Settings page under WooCommerce.

WooCommerce settings tab

I am wondering if there is a WordPress/WooCommerce of doing it, or do I need to just replicate it using custom code?

Edit: ideally it should be on my custom admin sub page, but guidance to add a new tab to WooCommerce->Settings is also appreciated.

1

1 Answer 1

0

I've figured it out how to do it on my custom admin page.

You can use default wordpress classes and get variable trickery like so:

<?php
    if( isset( $_GET[ 'tab' ] ) ) {
        $active_tab = $_GET[ 'tab' ];
    } // end if
?>

<h2 class="nav-tab-wrapper">
    <a href="?page=sandbox_theme_options&tab=display_options" class="nav-tab <?php echo $active_tab == 'display_options' ? 'nav-tab-active' : ''; ?>">Display Options</a>
    <a href="?page=sandbox_theme_options&tab=social_options" class="nav-tab <?php echo $active_tab == 'social_options' ? 'nav-tab-active' : ''; ?>">Social Options</a>
</h2>

And then wrap everything else in if($active_tab == 'desired_option'){} statements.

Credit: https://code.tutsplus.com/tutorials/the-wordpress-settings-api-part-5-tabbed-navigation-for-settings--wp-24971

Your Answer

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

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