Issue with re-ordering tabs
-
Hi,
I’m trying to customise the tabs on a Woocommerce store running the Generatepress theme and can’t seem to get the tabs re-ordered.
As part of the customisation, I’ve done the following:Renamed and changed the heading on the additional information tab to “Dimensions” – this worked fine.
Added a new tab based on a custom field called “Features” – this worked fine.
I’ve then tried to re-order the tabs using the code from the Woo site so instead of the original order of:
Description > Dimensions > Features
it should be
Description > Features > Dimensions
However, all that is happening is that they stay in the same order and a gap appears inbetween the first and second tabs.
Code added is as follows:
/**
* Rename product data tabs
*/
add_filter( ‘woocommerce_product_tabs’, ‘woo_rename_tabs’, 98 );
function woo_rename_tabs( $tabs ) {$tabs[‘additional_information’][‘title’] = __( ‘Dimensions’ ); // Rename the additional information tab
return $tabs;
}
/**
* Change the heading on the Additional Information tab section title for single products.
*/
add_filter( ‘woocommerce_product_additional_information_heading’, ‘isa_additional_info_heading’ );function isa_additional_info_heading() {
return ‘Dimensions’;
}add_filter( ‘woocommerce_product_tabs’, ‘woo_new_product_tab’ );
function woo_new_product_tab( $tabs ) {// Adds the new tab
$tabs[‘test_tab’] = array(
‘title’ => __( ‘Features’, ‘woocommerce’ ),
‘priority’ => 50,
‘callback’ => ‘woo_new_product_tab_content’
);return $tabs;
}
function woo_new_product_tab_content() {// The new tab content
echo ‘<h2>Features</h2>’;
echo get_field(‘features’, $post_id);}
/**
* Reorder product data tabs
*/
add_filter( ‘woocommerce_product_tabs’, ‘woo_reorder_tabs’, 98 );
function woo_reorder_tabs( $tabs ) {$tabs[‘description’][‘priority’] = 5; // Reviews first
$tabs[‘Features’][‘priority’] = 10; // Description second
$tabs[‘additional_information’][‘priority’] = 15; // Additional information thirdreturn $tabs;
}Any help would be appreciated ??
The page I need help with: [log in to see the link]
- The topic ‘Issue with re-ordering tabs’ is closed to new replies.