322

How to Add WooCommerce Checkout Field Labels Inside Input Boxes

Powered by WPCodeBox

Learn how to easily add WooCommerce checkout field labels inside input boxes for a cleaner, more intuitive user experience on your e-commerce site.


/**
 * Author: WP Turned UP
 * Author URI: https://wpturnedup.com
 */


add_filter( 'woocommerce_checkout_fields', 'wptu_labels_inside_checkout_fields', 9999 );
   
function wptu_labels_inside_checkout_fields( $fields ) {
   foreach ( $fields as $section => $section_fields ) {
      foreach ( $section_fields as $section_field => $section_field_settings ) {
         $fields[$section][$section_field]['placeholder'] = $fields[$section][$section_field]['label'];
         $fields[$section][$section_field]['label'] = '';
      }
   }
   return $fields;
}

Other Snippets

WPCodeBox is a WordPress Code Snippets Manager that allows you to share your WordPress Code Snippets across your sites.