Search code examples
wordpresswoocommerceproductfield-description

renaming product description title with custom sentence including product name


i've been trying to write

WHY 'MY PRODUCT TITLE'

In the product description tab, i've successfully renamed it with

'MY PRODUCT TITLE'

but i can't type the remaining word

WHY

in the description title tab.

the code i used is given below:

 add_filter( 'woocommerce_product_tabs', 
            'wc_change_product_description_tab_title', 10, 1 );
           function wc_change_product_description_tab_title( $tabs ) {
              global $post;
                if ( isset( $tabs['description']['title'] ) )
                $tabs['description']['title'] =  $post->post_title;
              return $tabs; 
}  

this code prints the product title and when i try this code so that i can type

why

any help is greatly appreciated


Solution

  • add_filter( 'woocommerce_product_tabs',
    'wc_change_product_description_tab_title', 10, 1 );
    function wc_change_product_description_tab_title( $tabs ) {
      global $post;
      if ( isset( $tabs['description']['title'] ) )
      $tabs['description']['title'] =  'WHY'.' '.$post->post_title;
      return $tabs;
    }