WooCommerce Checkout Field Labels Inside Input Boxes

Recommendation

Learn why I switched to WPCodeBox for managing code snippets for myself and for my clients.

Instructions

Snippet Type: PHP

  1. Copy the snippet.
  2. Add the snippet using WPCodeBox.
  3. Follow any customization notes provided.
  4. Save the snippet.
  5. Enable the snippet.
  6. Test.

Snippet

woocommerce checkout labels inside input boxes after
				
					// WOOCOMMERCE CHEKCOUT FIELD LABELS INSIDE INPUT BOXES
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;
}