Adding multiple tabs to WooCommerce single product pagesHow to add several tabs in woocommerce?Woocommerce show comments by defautHow to add an ingredients custom tab to Woocommerce productsMove additional information tab from WooCommerce to second positionCustom metabox content displayed in single product additional tabs on WoocommerceHow do I change Eclipse to use spaces instead of tabs?Open link in new tab or windowWoocommerce Reorder single page hooks, description showing twiceHow to remove woocommerce tab?Reordering Woocommerce actions on single product pageWooCommerce Move Upsells into Tabs and display with short descriptionAdd content above the product short description on the product page in WooCommerceWoocommerce: delete “additional information” tabWoocommerce single product summary hook priorityMoving variable product dropdowns in WooCommerce
Should I intentionally omit previous work experience when applying for jobs?
Is purchasing foreign currency before going abroad a losing proposition?
What was the definition of "set" that resulted in Russell's Paradox
Why do players in the past play much longer tournaments than today's top players?
I wrote two alternate fugue expositions for one subject do both follow good harmonic conventions?
How is angular momentum conserved for the orbiting body if the centripetal force disappears?
How to know whether a Tamron lens is compatible with Canon EOS 60D?
Referring to different instances of the same character in time travel
Does throwing a penny at a train stop the train?
Is anyone advocating the promotion of homosexuality in UK schools?
Book where the stars go black due to aliens stopping human observation collapsing quantum possibilities
Who has taken "my" Managed package namespace? Can we find out?
Supporting developers who insist on using their pet language
Why didn't Thanos kill all the Dwarves on Nidavellir?
Can I call 112 to check a police officer's identity in the Czech Republic?
Did any of the founding fathers anticipate Lysander Spooner's criticism of the constitution?
What explains 9 speed cassettes price differences?
What's the minimum number of sensors for a hobby GPS waypoint-following UAV?
Storming Area 51
How were Martello towers supposed to work?
What would be the ideal melee weapon made of "Phase Metal"?
Do you know your 'KVZ's?
Is there any word for "disobedience to God"?
Was the Ford Model T black because of the speed black paint dries?
Adding multiple tabs to WooCommerce single product pages
How to add several tabs in woocommerce?Woocommerce show comments by defautHow to add an ingredients custom tab to Woocommerce productsMove additional information tab from WooCommerce to second positionCustom metabox content displayed in single product additional tabs on WoocommerceHow do I change Eclipse to use spaces instead of tabs?Open link in new tab or windowWoocommerce Reorder single page hooks, description showing twiceHow to remove woocommerce tab?Reordering Woocommerce actions on single product pageWooCommerce Move Upsells into Tabs and display with short descriptionAdd content above the product short description on the product page in WooCommerceWoocommerce: delete “additional information” tabWoocommerce single product summary hook priorityMoving variable product dropdowns in WooCommerce
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to add three custom tabs to WooCommerce. I have the code below and two of them show up but for some reason the attribute description tab does not show on the page. Not only that the Quantity pricing tab doesn't show its description. I have tried to move the different sections of code to different locations and I have checked the code for errors or missing sections. This is as close as I can get it.
My process is to basically remove the existing tabs that I don't want and then to add new ones in the order that I want them to appear.
I have a feeling that I am missing something.
You can see the site here: http://demo.bergdahl.com/product/6-oz-catridge/
Here's the code I am using:
// WooCommerce Tabs
// REMOVE EXISTING TABS
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs )
unset( $tabs['description'] ); // Remove the description tab
// unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
// ADD ATTRIBUTE DESCRIPTION TAB
add_filter( 'woocommerce_product_tabs', 'woo_attrib_desc_tab' );
function woo_attrib_desc_tab( $tabs )
// Adds the Attribute Description tab
$tabs['attrib_desc_tab'] = array(
'title' => __( 'Desc', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_attrib_desc_tab_content'
);
return $tabs;
// ADD QUANTITY PRICING TAB
add_filter( 'woocommerce_product_tabs', 'woo_qty_pricing_tab' );
function woo_qty_pricing_tab( $tabs )
// Adds the qty pricing tab
$tabs['qty_pricing_tab'] = array(
'title' => __( 'Quantity Pricing', 'woocommerce' ),
'priority' => 110,
'callback' => 'woo_qty_pricing_tab_content'
);
return $tabs;
// ADD OTHER PRODUCTS TAB
add_filter( 'woocommerce_product_tabs', 'woo_other_products_tab' );
function woo_other_products_tab( $tabs )
// Adds the other products tab
$tabs['other_products_tab'] = array(
'title' => __( 'Other Products', 'woocommerce' ),
'priority' => 120,
'callback' => 'woo_other_products_tab_content'
);
return $tabs;
// ADD CUSTOM TAB DESCRIPTIONS
function woo_attrib_desc_tab_content()
// The attribute description tab content
echo '<h2>Description</h2>';
echo '<p>Custom description tab.</p>';
function woo_qty_pricing_tab_content()
// The qty pricing tab content
echo '<h2>Quantity Pricing</h2>';
echo '<p>Here's your quantity pricing tab.</p>';
function woo_other_products_tab_content()
// The other products tab content
echo '<h2>Other Products</h2>';
echo '<p>Here's your other products tab.</p>';
Edit per reply from LoicTheAztec below, this is my entire functions.php file. I tried it with and without the ?>
at the bottom:
<?php
add_theme_support( 'builder-3.0' );
add_theme_support( 'builder-responsive' );
function register_my_fonts()
wp_register_style('googleFonts-OpenSans', '//fonts.googleapis.com/css?family=Open+Sans:400,300,700');
wp_enqueue_style( 'googleFonts-OpenSans');
add_action('wp_enqueue_scripts', 'register_my_fonts');
function sc_replacecolon( $content ) return str_replace( '[sc:', '[sc name=', $content );
add_filter( 'the_content', 'sc_replacecolon', 5 );
/* WOOCOMMERCE */
add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tabs', 100, 1 );
function woo_custom_product_tabs( $tabs )
// 1) Removing tabs
unset( $tabs['description'] ); // Remove the description tab
// unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
// 2 Adding new tabs
//Attribute Description tab
$tabs['attrib_desc_tab'] = array(
'title' => __( 'Desc', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_attrib_desc_tab_content'
);
// Adds the qty pricing tab
$tabs['qty_pricing_tab'] = array(
'title' => __( 'Quantity Pricing', 'woocommerce' ),
'priority' => 110,
'callback' => 'woo_qty_pricing_tab_content'
);
// Adds the other products tab
$tabs['other_products_tab'] = array(
'title' => __( 'Other Products', 'woocommerce' ),
'priority' => 120,
'callback' => 'woo_other_products_tab_content'
);
return $tabs;
// New Tab contents
function woo_attrib_desc_tab_content()
// The attribute description tab content
echo '<h2>Description</h2>';
echo '<p>Custom description tab.</p>';
function woo_qty_pricing_tab_content()
// The qty pricing tab content
echo '<h2>Quantity Pricing</h2>';
echo '<p>Here's your quantity pricing tab.</p>';
function woo_other_products_tab_content()
// The other products tab content
echo '<h2>Other Products</h2>';
echo '<p>Here's your other products tab.</p>';
?>
php wordpress tabs woocommerce product
add a comment |
I am trying to add three custom tabs to WooCommerce. I have the code below and two of them show up but for some reason the attribute description tab does not show on the page. Not only that the Quantity pricing tab doesn't show its description. I have tried to move the different sections of code to different locations and I have checked the code for errors or missing sections. This is as close as I can get it.
My process is to basically remove the existing tabs that I don't want and then to add new ones in the order that I want them to appear.
I have a feeling that I am missing something.
You can see the site here: http://demo.bergdahl.com/product/6-oz-catridge/
Here's the code I am using:
// WooCommerce Tabs
// REMOVE EXISTING TABS
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs )
unset( $tabs['description'] ); // Remove the description tab
// unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
// ADD ATTRIBUTE DESCRIPTION TAB
add_filter( 'woocommerce_product_tabs', 'woo_attrib_desc_tab' );
function woo_attrib_desc_tab( $tabs )
// Adds the Attribute Description tab
$tabs['attrib_desc_tab'] = array(
'title' => __( 'Desc', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_attrib_desc_tab_content'
);
return $tabs;
// ADD QUANTITY PRICING TAB
add_filter( 'woocommerce_product_tabs', 'woo_qty_pricing_tab' );
function woo_qty_pricing_tab( $tabs )
// Adds the qty pricing tab
$tabs['qty_pricing_tab'] = array(
'title' => __( 'Quantity Pricing', 'woocommerce' ),
'priority' => 110,
'callback' => 'woo_qty_pricing_tab_content'
);
return $tabs;
// ADD OTHER PRODUCTS TAB
add_filter( 'woocommerce_product_tabs', 'woo_other_products_tab' );
function woo_other_products_tab( $tabs )
// Adds the other products tab
$tabs['other_products_tab'] = array(
'title' => __( 'Other Products', 'woocommerce' ),
'priority' => 120,
'callback' => 'woo_other_products_tab_content'
);
return $tabs;
// ADD CUSTOM TAB DESCRIPTIONS
function woo_attrib_desc_tab_content()
// The attribute description tab content
echo '<h2>Description</h2>';
echo '<p>Custom description tab.</p>';
function woo_qty_pricing_tab_content()
// The qty pricing tab content
echo '<h2>Quantity Pricing</h2>';
echo '<p>Here's your quantity pricing tab.</p>';
function woo_other_products_tab_content()
// The other products tab content
echo '<h2>Other Products</h2>';
echo '<p>Here's your other products tab.</p>';
Edit per reply from LoicTheAztec below, this is my entire functions.php file. I tried it with and without the ?>
at the bottom:
<?php
add_theme_support( 'builder-3.0' );
add_theme_support( 'builder-responsive' );
function register_my_fonts()
wp_register_style('googleFonts-OpenSans', '//fonts.googleapis.com/css?family=Open+Sans:400,300,700');
wp_enqueue_style( 'googleFonts-OpenSans');
add_action('wp_enqueue_scripts', 'register_my_fonts');
function sc_replacecolon( $content ) return str_replace( '[sc:', '[sc name=', $content );
add_filter( 'the_content', 'sc_replacecolon', 5 );
/* WOOCOMMERCE */
add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tabs', 100, 1 );
function woo_custom_product_tabs( $tabs )
// 1) Removing tabs
unset( $tabs['description'] ); // Remove the description tab
// unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
// 2 Adding new tabs
//Attribute Description tab
$tabs['attrib_desc_tab'] = array(
'title' => __( 'Desc', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_attrib_desc_tab_content'
);
// Adds the qty pricing tab
$tabs['qty_pricing_tab'] = array(
'title' => __( 'Quantity Pricing', 'woocommerce' ),
'priority' => 110,
'callback' => 'woo_qty_pricing_tab_content'
);
// Adds the other products tab
$tabs['other_products_tab'] = array(
'title' => __( 'Other Products', 'woocommerce' ),
'priority' => 120,
'callback' => 'woo_other_products_tab_content'
);
return $tabs;
// New Tab contents
function woo_attrib_desc_tab_content()
// The attribute description tab content
echo '<h2>Description</h2>';
echo '<p>Custom description tab.</p>';
function woo_qty_pricing_tab_content()
// The qty pricing tab content
echo '<h2>Quantity Pricing</h2>';
echo '<p>Here's your quantity pricing tab.</p>';
function woo_other_products_tab_content()
// The other products tab content
echo '<h2>Other Products</h2>';
echo '<p>Here's your other products tab.</p>';
?>
php wordpress tabs woocommerce product
"It broke the site" is 95% of the time a syntax error. You can get a more useful error description by enablingWP_DEBUG
.
– helgatheviking
Oct 10 '16 at 20:16
I added Loic's code below to the top of my functions.php and get: Parse error: syntax error, unexpected 'add_filter' (T_STRING) in /home/parkymay/public_html/demo/wp-content/themes/BuilderChild-Default/functions.php on line 1
– MattM
Oct 10 '16 at 20:25
The error says it is on line 1, which if I had to guess, indicates an issue with the parent theme'sfunctions.php
. I used your entirefunctions.php
from above as a child theme of Twenty Sixteen and it doesn't produce any errors.
– helgatheviking
Oct 10 '16 at 21:00
Can you remove everything from the parentfunctions.php
and then add it back 1 function at a time?
– helgatheviking
Oct 10 '16 at 21:28
helgatheviking, I figured out a work around. I added the code to a custom-functions.php file in the parent theme and removed all references to it in the child theme. The parent functions.php file already called for the custom file if it existed so it worked great! Thanks for your suggestions, they really helped tracking down the problems.
– MattM
Oct 10 '16 at 21:41
add a comment |
I am trying to add three custom tabs to WooCommerce. I have the code below and two of them show up but for some reason the attribute description tab does not show on the page. Not only that the Quantity pricing tab doesn't show its description. I have tried to move the different sections of code to different locations and I have checked the code for errors or missing sections. This is as close as I can get it.
My process is to basically remove the existing tabs that I don't want and then to add new ones in the order that I want them to appear.
I have a feeling that I am missing something.
You can see the site here: http://demo.bergdahl.com/product/6-oz-catridge/
Here's the code I am using:
// WooCommerce Tabs
// REMOVE EXISTING TABS
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs )
unset( $tabs['description'] ); // Remove the description tab
// unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
// ADD ATTRIBUTE DESCRIPTION TAB
add_filter( 'woocommerce_product_tabs', 'woo_attrib_desc_tab' );
function woo_attrib_desc_tab( $tabs )
// Adds the Attribute Description tab
$tabs['attrib_desc_tab'] = array(
'title' => __( 'Desc', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_attrib_desc_tab_content'
);
return $tabs;
// ADD QUANTITY PRICING TAB
add_filter( 'woocommerce_product_tabs', 'woo_qty_pricing_tab' );
function woo_qty_pricing_tab( $tabs )
// Adds the qty pricing tab
$tabs['qty_pricing_tab'] = array(
'title' => __( 'Quantity Pricing', 'woocommerce' ),
'priority' => 110,
'callback' => 'woo_qty_pricing_tab_content'
);
return $tabs;
// ADD OTHER PRODUCTS TAB
add_filter( 'woocommerce_product_tabs', 'woo_other_products_tab' );
function woo_other_products_tab( $tabs )
// Adds the other products tab
$tabs['other_products_tab'] = array(
'title' => __( 'Other Products', 'woocommerce' ),
'priority' => 120,
'callback' => 'woo_other_products_tab_content'
);
return $tabs;
// ADD CUSTOM TAB DESCRIPTIONS
function woo_attrib_desc_tab_content()
// The attribute description tab content
echo '<h2>Description</h2>';
echo '<p>Custom description tab.</p>';
function woo_qty_pricing_tab_content()
// The qty pricing tab content
echo '<h2>Quantity Pricing</h2>';
echo '<p>Here's your quantity pricing tab.</p>';
function woo_other_products_tab_content()
// The other products tab content
echo '<h2>Other Products</h2>';
echo '<p>Here's your other products tab.</p>';
Edit per reply from LoicTheAztec below, this is my entire functions.php file. I tried it with and without the ?>
at the bottom:
<?php
add_theme_support( 'builder-3.0' );
add_theme_support( 'builder-responsive' );
function register_my_fonts()
wp_register_style('googleFonts-OpenSans', '//fonts.googleapis.com/css?family=Open+Sans:400,300,700');
wp_enqueue_style( 'googleFonts-OpenSans');
add_action('wp_enqueue_scripts', 'register_my_fonts');
function sc_replacecolon( $content ) return str_replace( '[sc:', '[sc name=', $content );
add_filter( 'the_content', 'sc_replacecolon', 5 );
/* WOOCOMMERCE */
add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tabs', 100, 1 );
function woo_custom_product_tabs( $tabs )
// 1) Removing tabs
unset( $tabs['description'] ); // Remove the description tab
// unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
// 2 Adding new tabs
//Attribute Description tab
$tabs['attrib_desc_tab'] = array(
'title' => __( 'Desc', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_attrib_desc_tab_content'
);
// Adds the qty pricing tab
$tabs['qty_pricing_tab'] = array(
'title' => __( 'Quantity Pricing', 'woocommerce' ),
'priority' => 110,
'callback' => 'woo_qty_pricing_tab_content'
);
// Adds the other products tab
$tabs['other_products_tab'] = array(
'title' => __( 'Other Products', 'woocommerce' ),
'priority' => 120,
'callback' => 'woo_other_products_tab_content'
);
return $tabs;
// New Tab contents
function woo_attrib_desc_tab_content()
// The attribute description tab content
echo '<h2>Description</h2>';
echo '<p>Custom description tab.</p>';
function woo_qty_pricing_tab_content()
// The qty pricing tab content
echo '<h2>Quantity Pricing</h2>';
echo '<p>Here's your quantity pricing tab.</p>';
function woo_other_products_tab_content()
// The other products tab content
echo '<h2>Other Products</h2>';
echo '<p>Here's your other products tab.</p>';
?>
php wordpress tabs woocommerce product
I am trying to add three custom tabs to WooCommerce. I have the code below and two of them show up but for some reason the attribute description tab does not show on the page. Not only that the Quantity pricing tab doesn't show its description. I have tried to move the different sections of code to different locations and I have checked the code for errors or missing sections. This is as close as I can get it.
My process is to basically remove the existing tabs that I don't want and then to add new ones in the order that I want them to appear.
I have a feeling that I am missing something.
You can see the site here: http://demo.bergdahl.com/product/6-oz-catridge/
Here's the code I am using:
// WooCommerce Tabs
// REMOVE EXISTING TABS
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs )
unset( $tabs['description'] ); // Remove the description tab
// unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
// ADD ATTRIBUTE DESCRIPTION TAB
add_filter( 'woocommerce_product_tabs', 'woo_attrib_desc_tab' );
function woo_attrib_desc_tab( $tabs )
// Adds the Attribute Description tab
$tabs['attrib_desc_tab'] = array(
'title' => __( 'Desc', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_attrib_desc_tab_content'
);
return $tabs;
// ADD QUANTITY PRICING TAB
add_filter( 'woocommerce_product_tabs', 'woo_qty_pricing_tab' );
function woo_qty_pricing_tab( $tabs )
// Adds the qty pricing tab
$tabs['qty_pricing_tab'] = array(
'title' => __( 'Quantity Pricing', 'woocommerce' ),
'priority' => 110,
'callback' => 'woo_qty_pricing_tab_content'
);
return $tabs;
// ADD OTHER PRODUCTS TAB
add_filter( 'woocommerce_product_tabs', 'woo_other_products_tab' );
function woo_other_products_tab( $tabs )
// Adds the other products tab
$tabs['other_products_tab'] = array(
'title' => __( 'Other Products', 'woocommerce' ),
'priority' => 120,
'callback' => 'woo_other_products_tab_content'
);
return $tabs;
// ADD CUSTOM TAB DESCRIPTIONS
function woo_attrib_desc_tab_content()
// The attribute description tab content
echo '<h2>Description</h2>';
echo '<p>Custom description tab.</p>';
function woo_qty_pricing_tab_content()
// The qty pricing tab content
echo '<h2>Quantity Pricing</h2>';
echo '<p>Here's your quantity pricing tab.</p>';
function woo_other_products_tab_content()
// The other products tab content
echo '<h2>Other Products</h2>';
echo '<p>Here's your other products tab.</p>';
Edit per reply from LoicTheAztec below, this is my entire functions.php file. I tried it with and without the ?>
at the bottom:
<?php
add_theme_support( 'builder-3.0' );
add_theme_support( 'builder-responsive' );
function register_my_fonts()
wp_register_style('googleFonts-OpenSans', '//fonts.googleapis.com/css?family=Open+Sans:400,300,700');
wp_enqueue_style( 'googleFonts-OpenSans');
add_action('wp_enqueue_scripts', 'register_my_fonts');
function sc_replacecolon( $content ) return str_replace( '[sc:', '[sc name=', $content );
add_filter( 'the_content', 'sc_replacecolon', 5 );
/* WOOCOMMERCE */
add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tabs', 100, 1 );
function woo_custom_product_tabs( $tabs )
// 1) Removing tabs
unset( $tabs['description'] ); // Remove the description tab
// unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
// 2 Adding new tabs
//Attribute Description tab
$tabs['attrib_desc_tab'] = array(
'title' => __( 'Desc', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_attrib_desc_tab_content'
);
// Adds the qty pricing tab
$tabs['qty_pricing_tab'] = array(
'title' => __( 'Quantity Pricing', 'woocommerce' ),
'priority' => 110,
'callback' => 'woo_qty_pricing_tab_content'
);
// Adds the other products tab
$tabs['other_products_tab'] = array(
'title' => __( 'Other Products', 'woocommerce' ),
'priority' => 120,
'callback' => 'woo_other_products_tab_content'
);
return $tabs;
// New Tab contents
function woo_attrib_desc_tab_content()
// The attribute description tab content
echo '<h2>Description</h2>';
echo '<p>Custom description tab.</p>';
function woo_qty_pricing_tab_content()
// The qty pricing tab content
echo '<h2>Quantity Pricing</h2>';
echo '<p>Here's your quantity pricing tab.</p>';
function woo_other_products_tab_content()
// The other products tab content
echo '<h2>Other Products</h2>';
echo '<p>Here's your other products tab.</p>';
?>
php wordpress tabs woocommerce product
php wordpress tabs woocommerce product
edited Mar 12 at 9:32
LoicTheAztec
105k15 gold badges87 silver badges127 bronze badges
105k15 gold badges87 silver badges127 bronze badges
asked Oct 10 '16 at 18:54
MattMMattM
1,3915 gold badges21 silver badges42 bronze badges
1,3915 gold badges21 silver badges42 bronze badges
"It broke the site" is 95% of the time a syntax error. You can get a more useful error description by enablingWP_DEBUG
.
– helgatheviking
Oct 10 '16 at 20:16
I added Loic's code below to the top of my functions.php and get: Parse error: syntax error, unexpected 'add_filter' (T_STRING) in /home/parkymay/public_html/demo/wp-content/themes/BuilderChild-Default/functions.php on line 1
– MattM
Oct 10 '16 at 20:25
The error says it is on line 1, which if I had to guess, indicates an issue with the parent theme'sfunctions.php
. I used your entirefunctions.php
from above as a child theme of Twenty Sixteen and it doesn't produce any errors.
– helgatheviking
Oct 10 '16 at 21:00
Can you remove everything from the parentfunctions.php
and then add it back 1 function at a time?
– helgatheviking
Oct 10 '16 at 21:28
helgatheviking, I figured out a work around. I added the code to a custom-functions.php file in the parent theme and removed all references to it in the child theme. The parent functions.php file already called for the custom file if it existed so it worked great! Thanks for your suggestions, they really helped tracking down the problems.
– MattM
Oct 10 '16 at 21:41
add a comment |
"It broke the site" is 95% of the time a syntax error. You can get a more useful error description by enablingWP_DEBUG
.
– helgatheviking
Oct 10 '16 at 20:16
I added Loic's code below to the top of my functions.php and get: Parse error: syntax error, unexpected 'add_filter' (T_STRING) in /home/parkymay/public_html/demo/wp-content/themes/BuilderChild-Default/functions.php on line 1
– MattM
Oct 10 '16 at 20:25
The error says it is on line 1, which if I had to guess, indicates an issue with the parent theme'sfunctions.php
. I used your entirefunctions.php
from above as a child theme of Twenty Sixteen and it doesn't produce any errors.
– helgatheviking
Oct 10 '16 at 21:00
Can you remove everything from the parentfunctions.php
and then add it back 1 function at a time?
– helgatheviking
Oct 10 '16 at 21:28
helgatheviking, I figured out a work around. I added the code to a custom-functions.php file in the parent theme and removed all references to it in the child theme. The parent functions.php file already called for the custom file if it existed so it worked great! Thanks for your suggestions, they really helped tracking down the problems.
– MattM
Oct 10 '16 at 21:41
"It broke the site" is 95% of the time a syntax error. You can get a more useful error description by enabling
WP_DEBUG
.– helgatheviking
Oct 10 '16 at 20:16
"It broke the site" is 95% of the time a syntax error. You can get a more useful error description by enabling
WP_DEBUG
.– helgatheviking
Oct 10 '16 at 20:16
I added Loic's code below to the top of my functions.php and get: Parse error: syntax error, unexpected 'add_filter' (T_STRING) in /home/parkymay/public_html/demo/wp-content/themes/BuilderChild-Default/functions.php on line 1
– MattM
Oct 10 '16 at 20:25
I added Loic's code below to the top of my functions.php and get: Parse error: syntax error, unexpected 'add_filter' (T_STRING) in /home/parkymay/public_html/demo/wp-content/themes/BuilderChild-Default/functions.php on line 1
– MattM
Oct 10 '16 at 20:25
The error says it is on line 1, which if I had to guess, indicates an issue with the parent theme's
functions.php
. I used your entire functions.php
from above as a child theme of Twenty Sixteen and it doesn't produce any errors.– helgatheviking
Oct 10 '16 at 21:00
The error says it is on line 1, which if I had to guess, indicates an issue with the parent theme's
functions.php
. I used your entire functions.php
from above as a child theme of Twenty Sixteen and it doesn't produce any errors.– helgatheviking
Oct 10 '16 at 21:00
Can you remove everything from the parent
functions.php
and then add it back 1 function at a time?– helgatheviking
Oct 10 '16 at 21:28
Can you remove everything from the parent
functions.php
and then add it back 1 function at a time?– helgatheviking
Oct 10 '16 at 21:28
helgatheviking, I figured out a work around. I added the code to a custom-functions.php file in the parent theme and removed all references to it in the child theme. The parent functions.php file already called for the custom file if it existed so it worked great! Thanks for your suggestions, they really helped tracking down the problems.
– MattM
Oct 10 '16 at 21:41
helgatheviking, I figured out a work around. I added the code to a custom-functions.php file in the parent theme and removed all references to it in the child theme. The parent functions.php file already called for the custom file if it existed so it worked great! Thanks for your suggestions, they really helped tracking down the problems.
– MattM
Oct 10 '16 at 21:41
add a comment |
2 Answers
2
active
oldest
votes
As you are using 4 times the same hook woocommerce_product_tabs
, your problem comes from the highest priority on the first one. Instead you should use it only one time, merging that 4 hooked functions in one.
Here is your functional tested code, changed a little bit:
add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tabs' );
function woo_custom_product_tabs( $tabs )
// 1) Removing tabs
unset( $tabs['description'] ); // Remove the description tab
// unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
// 2 Adding new tabs and set the right order
//Attribute Description tab
$tabs['attrib_desc_tab'] = array(
'title' => __( 'Desc', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_attrib_desc_tab_content'
);
// Adds the qty pricing tab
$tabs['qty_pricing_tab'] = array(
'title' => __( 'Quantity Pricing', 'woocommerce' ),
'priority' => 110,
'callback' => 'woo_qty_pricing_tab_content'
);
// Adds the other products tab
$tabs['other_products_tab'] = array(
'title' => __( 'Other Products', 'woocommerce' ),
'priority' => 120,
'callback' => 'woo_other_products_tab_content'
);
return $tabs;
// New Tab contents
function woo_attrib_desc_tab_content()
// The attribute description tab content
echo '<h2>Description</h2>';
echo '<p>Custom description tab.</p>';
function woo_qty_pricing_tab_content()
// The qty pricing tab content
echo '<h2>Quantity Pricing</h2>';
echo '<p>Here's your quantity pricing tab.</p>';
function woo_other_products_tab_content()
// The other products tab content
echo '<h2>Other Products</h2>';
echo '<p>Here's your other products tab.</p>';
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Tested and works.
In the same hook, you can:
- Remove tabs
- Add tabs
- Reorder tabs
Related official documentation: Editing product data tabs
1
Tested this and it is working for me (don't think you need the 100 priority, but it isn't hurting anything), so there's probably a syntax error somewhere else in yourfunctions.php
. As I advised above you should enableWP_DEBUG
to find out where.
– helgatheviking
Oct 10 '16 at 20:21
add a comment |
The only addition I made was to check whether content existed in a tab before adding it. I simply wrapped each new array with an 'if' statement.
if (!empty(get_the_content()))
$tabs['tab'] = array(
'title' => __( 'Tab Title', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_tab_content'
);
add a comment |
protected by LoicTheAztec Mar 12 at 9:31
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
As you are using 4 times the same hook woocommerce_product_tabs
, your problem comes from the highest priority on the first one. Instead you should use it only one time, merging that 4 hooked functions in one.
Here is your functional tested code, changed a little bit:
add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tabs' );
function woo_custom_product_tabs( $tabs )
// 1) Removing tabs
unset( $tabs['description'] ); // Remove the description tab
// unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
// 2 Adding new tabs and set the right order
//Attribute Description tab
$tabs['attrib_desc_tab'] = array(
'title' => __( 'Desc', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_attrib_desc_tab_content'
);
// Adds the qty pricing tab
$tabs['qty_pricing_tab'] = array(
'title' => __( 'Quantity Pricing', 'woocommerce' ),
'priority' => 110,
'callback' => 'woo_qty_pricing_tab_content'
);
// Adds the other products tab
$tabs['other_products_tab'] = array(
'title' => __( 'Other Products', 'woocommerce' ),
'priority' => 120,
'callback' => 'woo_other_products_tab_content'
);
return $tabs;
// New Tab contents
function woo_attrib_desc_tab_content()
// The attribute description tab content
echo '<h2>Description</h2>';
echo '<p>Custom description tab.</p>';
function woo_qty_pricing_tab_content()
// The qty pricing tab content
echo '<h2>Quantity Pricing</h2>';
echo '<p>Here's your quantity pricing tab.</p>';
function woo_other_products_tab_content()
// The other products tab content
echo '<h2>Other Products</h2>';
echo '<p>Here's your other products tab.</p>';
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Tested and works.
In the same hook, you can:
- Remove tabs
- Add tabs
- Reorder tabs
Related official documentation: Editing product data tabs
1
Tested this and it is working for me (don't think you need the 100 priority, but it isn't hurting anything), so there's probably a syntax error somewhere else in yourfunctions.php
. As I advised above you should enableWP_DEBUG
to find out where.
– helgatheviking
Oct 10 '16 at 20:21
add a comment |
As you are using 4 times the same hook woocommerce_product_tabs
, your problem comes from the highest priority on the first one. Instead you should use it only one time, merging that 4 hooked functions in one.
Here is your functional tested code, changed a little bit:
add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tabs' );
function woo_custom_product_tabs( $tabs )
// 1) Removing tabs
unset( $tabs['description'] ); // Remove the description tab
// unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
// 2 Adding new tabs and set the right order
//Attribute Description tab
$tabs['attrib_desc_tab'] = array(
'title' => __( 'Desc', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_attrib_desc_tab_content'
);
// Adds the qty pricing tab
$tabs['qty_pricing_tab'] = array(
'title' => __( 'Quantity Pricing', 'woocommerce' ),
'priority' => 110,
'callback' => 'woo_qty_pricing_tab_content'
);
// Adds the other products tab
$tabs['other_products_tab'] = array(
'title' => __( 'Other Products', 'woocommerce' ),
'priority' => 120,
'callback' => 'woo_other_products_tab_content'
);
return $tabs;
// New Tab contents
function woo_attrib_desc_tab_content()
// The attribute description tab content
echo '<h2>Description</h2>';
echo '<p>Custom description tab.</p>';
function woo_qty_pricing_tab_content()
// The qty pricing tab content
echo '<h2>Quantity Pricing</h2>';
echo '<p>Here's your quantity pricing tab.</p>';
function woo_other_products_tab_content()
// The other products tab content
echo '<h2>Other Products</h2>';
echo '<p>Here's your other products tab.</p>';
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Tested and works.
In the same hook, you can:
- Remove tabs
- Add tabs
- Reorder tabs
Related official documentation: Editing product data tabs
1
Tested this and it is working for me (don't think you need the 100 priority, but it isn't hurting anything), so there's probably a syntax error somewhere else in yourfunctions.php
. As I advised above you should enableWP_DEBUG
to find out where.
– helgatheviking
Oct 10 '16 at 20:21
add a comment |
As you are using 4 times the same hook woocommerce_product_tabs
, your problem comes from the highest priority on the first one. Instead you should use it only one time, merging that 4 hooked functions in one.
Here is your functional tested code, changed a little bit:
add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tabs' );
function woo_custom_product_tabs( $tabs )
// 1) Removing tabs
unset( $tabs['description'] ); // Remove the description tab
// unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
// 2 Adding new tabs and set the right order
//Attribute Description tab
$tabs['attrib_desc_tab'] = array(
'title' => __( 'Desc', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_attrib_desc_tab_content'
);
// Adds the qty pricing tab
$tabs['qty_pricing_tab'] = array(
'title' => __( 'Quantity Pricing', 'woocommerce' ),
'priority' => 110,
'callback' => 'woo_qty_pricing_tab_content'
);
// Adds the other products tab
$tabs['other_products_tab'] = array(
'title' => __( 'Other Products', 'woocommerce' ),
'priority' => 120,
'callback' => 'woo_other_products_tab_content'
);
return $tabs;
// New Tab contents
function woo_attrib_desc_tab_content()
// The attribute description tab content
echo '<h2>Description</h2>';
echo '<p>Custom description tab.</p>';
function woo_qty_pricing_tab_content()
// The qty pricing tab content
echo '<h2>Quantity Pricing</h2>';
echo '<p>Here's your quantity pricing tab.</p>';
function woo_other_products_tab_content()
// The other products tab content
echo '<h2>Other Products</h2>';
echo '<p>Here's your other products tab.</p>';
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Tested and works.
In the same hook, you can:
- Remove tabs
- Add tabs
- Reorder tabs
Related official documentation: Editing product data tabs
As you are using 4 times the same hook woocommerce_product_tabs
, your problem comes from the highest priority on the first one. Instead you should use it only one time, merging that 4 hooked functions in one.
Here is your functional tested code, changed a little bit:
add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tabs' );
function woo_custom_product_tabs( $tabs )
// 1) Removing tabs
unset( $tabs['description'] ); // Remove the description tab
// unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
// 2 Adding new tabs and set the right order
//Attribute Description tab
$tabs['attrib_desc_tab'] = array(
'title' => __( 'Desc', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_attrib_desc_tab_content'
);
// Adds the qty pricing tab
$tabs['qty_pricing_tab'] = array(
'title' => __( 'Quantity Pricing', 'woocommerce' ),
'priority' => 110,
'callback' => 'woo_qty_pricing_tab_content'
);
// Adds the other products tab
$tabs['other_products_tab'] = array(
'title' => __( 'Other Products', 'woocommerce' ),
'priority' => 120,
'callback' => 'woo_other_products_tab_content'
);
return $tabs;
// New Tab contents
function woo_attrib_desc_tab_content()
// The attribute description tab content
echo '<h2>Description</h2>';
echo '<p>Custom description tab.</p>';
function woo_qty_pricing_tab_content()
// The qty pricing tab content
echo '<h2>Quantity Pricing</h2>';
echo '<p>Here's your quantity pricing tab.</p>';
function woo_other_products_tab_content()
// The other products tab content
echo '<h2>Other Products</h2>';
echo '<p>Here's your other products tab.</p>';
This code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Tested and works.
In the same hook, you can:
- Remove tabs
- Add tabs
- Reorder tabs
Related official documentation: Editing product data tabs
edited Dec 29 '17 at 12:59
answered Oct 10 '16 at 19:34
LoicTheAztecLoicTheAztec
105k15 gold badges87 silver badges127 bronze badges
105k15 gold badges87 silver badges127 bronze badges
1
Tested this and it is working for me (don't think you need the 100 priority, but it isn't hurting anything), so there's probably a syntax error somewhere else in yourfunctions.php
. As I advised above you should enableWP_DEBUG
to find out where.
– helgatheviking
Oct 10 '16 at 20:21
add a comment |
1
Tested this and it is working for me (don't think you need the 100 priority, but it isn't hurting anything), so there's probably a syntax error somewhere else in yourfunctions.php
. As I advised above you should enableWP_DEBUG
to find out where.
– helgatheviking
Oct 10 '16 at 20:21
1
1
Tested this and it is working for me (don't think you need the 100 priority, but it isn't hurting anything), so there's probably a syntax error somewhere else in your
functions.php
. As I advised above you should enable WP_DEBUG
to find out where.– helgatheviking
Oct 10 '16 at 20:21
Tested this and it is working for me (don't think you need the 100 priority, but it isn't hurting anything), so there's probably a syntax error somewhere else in your
functions.php
. As I advised above you should enable WP_DEBUG
to find out where.– helgatheviking
Oct 10 '16 at 20:21
add a comment |
The only addition I made was to check whether content existed in a tab before adding it. I simply wrapped each new array with an 'if' statement.
if (!empty(get_the_content()))
$tabs['tab'] = array(
'title' => __( 'Tab Title', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_tab_content'
);
add a comment |
The only addition I made was to check whether content existed in a tab before adding it. I simply wrapped each new array with an 'if' statement.
if (!empty(get_the_content()))
$tabs['tab'] = array(
'title' => __( 'Tab Title', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_tab_content'
);
add a comment |
The only addition I made was to check whether content existed in a tab before adding it. I simply wrapped each new array with an 'if' statement.
if (!empty(get_the_content()))
$tabs['tab'] = array(
'title' => __( 'Tab Title', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_tab_content'
);
The only addition I made was to check whether content existed in a tab before adding it. I simply wrapped each new array with an 'if' statement.
if (!empty(get_the_content()))
$tabs['tab'] = array(
'title' => __( 'Tab Title', 'woocommerce' ),
'priority' => 100,
'callback' => 'woo_tab_content'
);
answered Oct 11 '17 at 8:12
Carl CahillCarl Cahill
11 bronze badge
11 bronze badge
add a comment |
add a comment |
protected by LoicTheAztec Mar 12 at 9:31
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
"It broke the site" is 95% of the time a syntax error. You can get a more useful error description by enabling
WP_DEBUG
.– helgatheviking
Oct 10 '16 at 20:16
I added Loic's code below to the top of my functions.php and get: Parse error: syntax error, unexpected 'add_filter' (T_STRING) in /home/parkymay/public_html/demo/wp-content/themes/BuilderChild-Default/functions.php on line 1
– MattM
Oct 10 '16 at 20:25
The error says it is on line 1, which if I had to guess, indicates an issue with the parent theme's
functions.php
. I used your entirefunctions.php
from above as a child theme of Twenty Sixteen and it doesn't produce any errors.– helgatheviking
Oct 10 '16 at 21:00
Can you remove everything from the parent
functions.php
and then add it back 1 function at a time?– helgatheviking
Oct 10 '16 at 21:28
helgatheviking, I figured out a work around. I added the code to a custom-functions.php file in the parent theme and removed all references to it in the child theme. The parent functions.php file already called for the custom file if it existed so it worked great! Thanks for your suggestions, they really helped tracking down the problems.
– MattM
Oct 10 '16 at 21:41