# Local Business Structured Data

> Adds LocalBusiness JSON-LD with your address, phone, opening hours and map location to the homepage, to support local search and map results.

- Type: PHP
- Runs: Frontend only
- Category: [SEO](https://wpide.com/library/category/seo/)
- Tags: schema, local-seo, business
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/local-business-schema/

## Code

```php
// Your business details.
$wpide_business = array(
    'type'      => 'LocalBusiness',
    'name'      => 'Acme Coffee Roasters',
    'phone'     => '+1-555-010-0199',
    'street'    => '123 Main Street',
    'city'      => 'Springfield',
    'region'    => 'IL',
    'postcode'  => '62701',
    'country'   => 'US',
    'latitude'  => '39.7817',
    'longitude' => '-89.6501',
    'price'     => '$$',
    // Opening hours: day codes Mo Tu We Th Fr Sa Su and 24h times.
    'hours'     => array( 'Mo-Fr 08:00-18:00', 'Sa 09:00-14:00' ),
);

add_action( 'wp_head', function () use ( $wpide_business ) {
    if ( ! is_front_page() ) {
        return;
    }

    $data = array(
        '@context'     => 'https://schema.org',
        '@type'        => $wpide_business['type'],
        'name'         => $wpide_business['name'],
        'url'          => home_url( '/' ),
        'telephone'    => $wpide_business['phone'],
        'priceRange'   => $wpide_business['price'],
        'address'      => array(
            '@type'           => 'PostalAddress',
            'streetAddress'   => $wpide_business['street'],
            'addressLocality' => $wpide_business['city'],
            'addressRegion'   => $wpide_business['region'],
            'postalCode'      => $wpide_business['postcode'],
            'addressCountry'  => $wpide_business['country'],
        ),
        'openingHours' => $wpide_business['hours'],
    );

    if ( $wpide_business['latitude'] && $wpide_business['longitude'] ) {
        $data['geo'] = array(
            '@type'     => 'GeoCoordinates',
            'latitude'  => $wpide_business['latitude'],
            'longitude' => $wpide_business['longitude'],
        );
    }

    if ( has_custom_logo() ) {
        $logo = wp_get_attachment_image_url( (int) get_theme_mod( 'custom_logo' ), 'full' );

        if ( $logo ) {
            $data['image'] = $logo;
        }
    }

    echo '<script type="application/ld+json">' . wp_json_encode( array_filter( $data ), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_HEX_TAG ) . "</script>\n";
} );
```

## Notes

Fill in your details at the top. Use a more specific type such as Restaurant, Dentist or Store when one fits.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Local Business Structured Data" 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/
