Title: PHP Function how to duplicate functio without redeclare error
Last modified: August 21, 2016

---

# PHP Function how to duplicate functio without redeclare error

 *  [culture-cross](https://wordpress.org/support/users/culture-cross/)
 * (@culture-cross)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/php-function-how-to-duplicate-functio-without-redeclare-error/)
 * Hello there!!
 * I am using a function to add tabs to a product page on my site, culture-cross.
   org
 * I added one tab using a function. I want to add two tabs. So When I add the function
   again to function.php to make the second tab, I get this error:
    Fatal error:
   Cannot redeclare woo_new_product_tab() (previously declared in /hermes/bosoraweb183/
   b1660/ipg.culturecrossorg1/test/wp-content/themes/MayaShop_WordPress_Theme/maya/
   functions.php:46) in /hermes/bosoraweb183/b1660/ipg.culturecrossorg1/test/wp-
   content/themes/MayaShop_WordPress_Theme/maya/functions.php on line 78
 * How do I add the function twice, to use it again?
 * This is the function:
 * add_filter( ‘woocommerce_product_tabs’, ‘woo_new_product_tab’ );
    function woo_new_product_tab(
   $tabs ) { // Adds the new tab $tabs[‘test_tab’] = array( ‘title’ => __( ‘Ask 
   a question’, ‘woocommerce’ ), ‘priority’ => 50, ‘callback’ => ‘woo_new_product_tab_content’);
 * return $tabs;
 * }
    function woo_new_product_tab_content() {
 * // The new tab content
 * echo ‘<h2>Have a question? Just ask!</h2>’;
    echo do_shortcode(‘[customcontact
   form=5]’);
 * }
 * THANK YOU!!!

Viewing 1 replies (of 1 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/php-function-how-to-duplicate-functio-without-redeclare-error/#post-4067975)
 * I think you can get what you want by adding a second filter with a different 
   function name:
 *     ```
       add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab2' );
       function woo_new_product_tab2( $tabs ) {
          // rest of code the same
       ```
   
 * You could also add the second tab inside the first function, but this way keeps
   the code separate.

Viewing 1 replies (of 1 total)

The topic ‘PHP Function how to duplicate functio without redeclare error’ is closed
to new replies.

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)
 * [function.php](https://wordpress.org/support/topic-tag/function-php/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [redeclare](https://wordpress.org/support/topic-tag/redeclare/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * Last activity: [12 years, 9 months ago](https://wordpress.org/support/topic/php-function-how-to-duplicate-functio-without-redeclare-error/#post-4067975)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
