# Put Postcode and City on One Row

> Places the postcode and city fields side by side on the checkout, which saves space and matches how many countries write addresses.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, checkout, fields, layout
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-postcode-city-one-row/

## Code

```php
add_filter( 'woocommerce_default_address_fields', function ( $fields ) {
    if ( isset( $fields['postcode'], $fields['city'] ) ) {
        $fields['postcode']['class'] = array( 'form-row-first', 'address-field' );
        $fields['city']['class']     = array( 'form-row-last', 'address-field' );
        $fields['city']['priority']  = $fields['postcode']['priority'] + 1;
    }

    return $fields;
}, 30 );
```

## Notes

On phones the two fields still stack, as with WooCommerce's first and last name fields.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Put Postcode and City on One Row" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
