• Hello,
    I’ve created a child theme for shophistic-lite.
    the child css is working however I created an empty functions.php and pasted this in as I want to add an additional information tab in my case called “Lorem ipsum”:

    <?php
    
    /*My custom functions*/
    
    add_filter( 'woocommerce_product_tabs', 'woo_custom_description_tab', 98 );
    function woo_custom_description_tab( $tabs ) {
    
    	$tabs['description']['callback'] = 'woo_custom_description_tab_content';	// Custom description callback
    
    	return $tabs;
    }
    
    function woo_custom_description_tab_content() {
    	echo '<h2>Art Specifications</h2>';
    	echo '<p><strong>Lorem ipsum here</strong></p>
                  <p>Lorem ipsum here</p>';
    }
    
    add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
    function woo_rename_tabs( $tabs ) {
    
        $tabs['description']['title'] = __( 'More Information' );       // Rename the description tab
     //   $tabs['reviews']['title'] = __( 'Ratings' );                // Rename the reviews tab
     //   $tabs['additional_information']['title'] = __( 'Product Data' );    // Rename the additional information tab
    
        return $tabs;
    
    ?>

    This code works if placed into the parent functions.php but not when I add it to the child functions.php.
    This would be lost when updating the parent theme so I need it in the child. Any help greatly appreciated. I’ve read the codex on creating child functions.php and I don’t know what I’m missing here????

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi there,

    In this case it’s not necessary to include the closing PHP tag, and often doing so can cause errors, especially if there is white space there. So try deleting that and see if that resolves the issue.

    Thread Starter ms_missy

    (@ms_missy)

    Hi dbking,
    Thanks for your response.
    I removed white space and the closing php tag and then got a parse error.
    I then removed the first function and replaced it with another (see below) and it’s working now:

    add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
    function woo_new_product_tab( $tabs ) {
    
    	// Adds the new tab
    
    	$tabs['test_tab'] = array(
    		'title' 	=> __( 'New Product Tab', 'woocommerce' ),
    		'priority' 	=> 50,
    		'callback' 	=> 'woo_new_product_tab_content'
    	);
    
    	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>';
    
    }

    For anyone else who is wanting to customise their tabs I found this helpful page

    Now all I have to do is change the order of the tabs!
    My custom tab is the 3rd tab and I wish it to be the 1st tab.

    Thread Starter ms_missy

    (@ms_missy)

    And I just changed the order of the tabs.
    Thought I’d write what I did for anyone else who wants to do this.
    See in the above code, where it says:
    ‘priority’ => 50,
    I changed it to :
    ‘priority’ => 1,

    and that is it!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘functions.php in child not working’ is closed to new replies.