Is it possible to pass the value of a customizer field value into a functions.php variable?

I want to provide a language option for custom WooCommerce tabs. Currently the headings for the tabs are hardcoded into functions.php. After removing the default tabs I add the following:

add_filter( 'woocommerce_product_tabs', 'downloads_tab' );
if ( ! function_exists ( 'downloads_tab' ) ) {
function downloads_tab( $tabs ) {
  // ensure ACF is available
  if ( !function_exists( 'have_rows' ) )

  if ( get_field('downloads') ) {
    $tabs['downloads_tab'] = array(
      'title'   => __( 'Downloads', 'woocommerce' ),
      'priority' => 60,
      'callback' => 'woo_downloads_tab_content'
  return $tabs;

In customizer.php (theme is based on UnderStrap) I have:

// Product Downloads Tab Setting
$wp_customize->add_setting( 'product-downloads-tab', array( 'default' => '' ) );
$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'product-downloads-tab', array( 'label' => __( 'Product "Downloads" tab text', 'theme-name' ), 'section' => 'language-options', 'settings' => 'product-downloads-tab', ) ) );

Can I use the value of whatever is entered here instead of hardcoding the tab title in functions.php?

My workaround is to override the function in the child theme's functions.php, but I'd rather give the client the ability to set the title of the tab.

1 Answer 1


Sure, every setting in the Customizer is saved either as a theme mod (by default) or option (if you set the 'type' to 'option' in $wp_customize->add_setting()).

You can access the user-defined value using get_theme_mod() (or get_option()).

In your example, the value you are looking for can be retrieved with:

$downloads_tab_text = get_theme_mod( 'product-downloads-tab' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.