Add Address and Contact Point to Yoast's Organization Schema
Extends the Organization piece of the Yoast SEO graph with your postal address, phone number, email and a customer service contact point.
Opens WPIDE on
Code
// Your organization's details.
$wpide_org = array(
'telephone' => '+1-555-010-0100',
'email' => '[email protected]',
'street' => '123 Main Street',
'city' => 'Springfield',
'region' => 'IL',
'postcode' => '62701',
'country' => 'US',
'support' => '+1-555-010-0101', // Customer service phone.
);
add_filter( 'wpseo_schema_organization', function ( $data ) use ( $wpide_org ) {
if ( ! is_array( $data ) ) {
return $data;
}
if ( $wpide_org['telephone'] ) {
$data['telephone'] = $wpide_org['telephone'];
}
if ( $wpide_org['email'] ) {
$data['email'] = $wpide_org['email'];
}
if ( $wpide_org['street'] ) {
$data['address'] = array(
'@type' => 'PostalAddress',
'streetAddress' => $wpide_org['street'],
'addressLocality' => $wpide_org['city'],
'addressRegion' => $wpide_org['region'],
'postalCode' => $wpide_org['postcode'],
'addressCountry' => $wpide_org['country'],
);
}
if ( $wpide_org['support'] ) {
$data['contactPoint'] = array(
'@type' => 'ContactPoint',
'telephone' => $wpide_org['support'],
'contactType' => 'customer service',
);
}
return $data;
} );
Notes
Fill in your details at the top; leave a value empty to skip it.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.