Skip to content

LocalBusiness schema generator for WordPress

Fill in a business's name, address, phone and hours and get its LocalBusiness structured data, as a small WordPress plugin file or as the block alone, with the properties Google documents. Made in your browser; nothing is sent.

The business

Google asks for the most specific kind that fits. If none here does, leave the first.

The name the business goes by, as on its sign and its site. No town or service added to it.

The address

The two-letter code, such as US, CA or GB.

Contact

The number customers should call, with the country code and the area code.

In full. For a business with one location this is usually the home page.

Such as $$ or $10-15.

Coordinates

Recommended. In a maps app, right-click the building to read them. Google asks for at least 5 decimal places.

Opening hours

Recommended. Give the hours your site shows. A day left as "Not stated" is left out. For hours that run past midnight, give the closing time on the day they began.

What to make

The plugin file needs no plugin installed: WordPress loads whatever is in wp-content/mu-plugins. The block alone can go in a Custom HTML block on the page.

Google says any page can carry it, and that it makes more sense on a page with information about the business.

Google requires a name and an address. Still to fill in: the business's name and its address.

local-business-markup.php
<?php
/**
 * Plugin Name: Local business markup
 * Description: Prints LocalBusiness structured data on the front page.
 *
 * Save this file as wp-content/mu-plugins/local-business-markup.php.
 * Keep it the same as what the page shows a visitor.
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

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

		$business = array(
			'@context' => 'https://schema.org',
			'@type' => 'LocalBusiness',
		);

		echo '<script type="application/ld+json">' . wp_json_encode( $business ) . '</script>' . "\n";
	}
);
Built in your browser from what you typed. A field left empty adds nothing to it.

What the block is for

LocalBusiness structured data tells a search engine, in a form it can read without guessing, what a business is called, where it is, how to reach it and when it is open. Google's documentation requires two things in it, a name and an address, and lists the rest as recommended. It does not say the block moves a page up the results, and it says outright that structured data is no guarantee that anything extra is shown.

What the file holds

  • Only the properties Google documents for a local business: the kind of business, its name and address, and, where you give them, a phone number, the address of its page, a price range, coordinates and opening hours.
  • Only what you filled in. A field left empty, or one that is not what it should be, such as a phone number with no country code, adds nothing to the file.
  • Hours as Google's documentation writes them. Days with the same hours share one entry. A day closed all day opens and closes at 00:00, which is how that documentation says to state it.
  • No rating and no reviews. Google lists those for a site that collects reviews about other businesses, and says a business's own pages about itself are not eligible for review stars. Why the stars do not show for a local business has the rule.

How to use it

The plugin file goes in wp-content/mu-plugins/, a folder WordPress loads every file from without anything being activated. Create the folder if it is not there, upload the file, then open the page and look in its source for application/ld+json. Google's Rich Results Test reads the same page and says what it found. To change a detail later, edit it in the file.

The block alone can go in a Custom HTML block on the page. If an SEO plugin on the site already prints LocalBusiness data, fill in its settings instead, so the page does not carry two blocks that disagree. How to add local business schema to WordPress covers each property and how to check for a block that is already there.

What it does not do

It does not check that the details are true or that they match the page: that part is yours. Google's guidelines say not to mark up what a visitor cannot see, so the name, address, phone and hours in the file should be the ones the page shows, and the ones on the business's Google Business Profile. It writes one business. A business with several branches needs a block on each branch's own page.

Nothing leaves your browser. The file is built on this page, and nothing you type is sent or kept.

Common questions

Will this get my business into the map results?
No tool can say that. Google's help says local results are based mainly on relevance, distance and popularity, and that there is no way to request or pay for a better local ranking. The block describes the business accurately to a search engine. What appears for a search is Google's to decide.
Which page should carry it?
Google says any page can, and that it makes more sense on a page with information about the business. For a business with one location that is usually the home page or the contact page. For a business with branches, each branch's own page carries that branch's block.
Why can't I add my star rating?
Because Google does not show review stars for a business's own pages about itself, whatever the markup says. Its documentation lists a rating and reviews in this block only for sites that collect reviews about other businesses.
We go to our customers and show no street address. What do I put?
Google's page for this block does not cover that case. It requires an address and calls it the physical location of the business. You can give the parts your site does show, such as the town, the region and the postal code, and leave the street empty, so the block says no more than the page does. Whether an address without a street is enough for Google is not something its page says.
I already use an SEO plugin. Do I need this?
Check first. Open your home page's source and search for application/ld+json. If a block there already names your business as a LocalBusiness or one of its kinds, complete it in that plugin's settings rather than adding a second one.

Rather have it set up for you?

Tell us the address of the site. We check what it already tells a search engine about the business, add what is missing and test it, and reply with a fixed quote first. The diagnosis is free.

Get a free diagnosis