Skip to content

Instantly share code, notes, and snippets.

@alemarengo
Forked from jameskoster/functions.php
Last active August 29, 2015 14:18
Show Gist options
  • Save alemarengo/a6109beeeee01421b1ca to your computer and use it in GitHub Desktop.
Save alemarengo/a6109beeeee01421b1ca to your computer and use it in GitHub Desktop.
Woocommerce: trying to change priority, add a custom tab and hide description tab if void
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
global $post;
$tabs['description']['priority'] = 25;
$tabs['reviews']['priority'] = 55;
$tabs['test_tab'] = array(
'title' => __( 'test_tab', 'woocommerce' ),
'priority' => 50,
'callback' => 'woo_new_product_tab_content'
);
$exists = get_post_meta($post->ID, 'product_description', true);
if ($exists == "") {
unset($tabs['description']);
}
return $tabs;
}
function woo_new_product_tab_content() {
// The new tab content
echo '<h2>New Product Tab</h2>';
echo '<p>Here\'s your new product tab.</p>';
}
@alemarengo
Copy link
Author

Is there someone that can help me in finding why I cannot get test_tab? All the rest works greatly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment