Tell search engines your organisation's name, logo and social profiles, and which name to show for your site in results.
add_action( 'wp_head', function (): void {
if ( ! is_front_page() || defined( 'WPSEO_VERSION' ) || defined( 'RANK_MATH_VERSION' ) || defined( 'SLIM_SEO_VER' ) || defined( 'SEOPRESS_VERSION' ) || defined( 'AIOSEO_VERSION' ) ) {
return;
}
$name = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
$logo = has_custom_logo() ? wp_get_attachment_image_url( (int) get_theme_mod( 'custom_logo' ), 'full' ) : get_site_icon_url( 512 );
$organization = array_filter( [
'@type' => 'Organization',
'@id' => home_url( '/#organization' ),
'name' => $name,
'url' => home_url( '/' ),
'logo' => $logo ?: null,
'sameAs' => [
'https://www.linkedin.com/company/example',
'https://x.com/example',
],
] );
$website = [
'@type' => 'WebSite',
'@id' => home_url( '/#website' ),
'name' => $name,
'url' => home_url( '/' ),
'publisher' => [ '@id' => home_url( '/#organization' ) ],
];
echo '<script type="application/ld+json">' . wp_json_encode( [ '@context' => 'https://schema.org', '@graph' => [ $organization, $website ] ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_HEX_TAG ) . "</script>\n";
} );
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
Structured data on your homepage tells search engines who runs the site: the organisation’s name, logo and official social profiles. The WebSite part also tells Google which name to show for your site above search results.
On the front page only, the snippet prints a JSON-LD @graph with two linked items. The Organization uses your site title, your Customizer logo (or the site icon if there’s no logo) and the profile URLs in sameAs. The WebSite uses the same name and points to the Organization as its publisher.
Empty values are removed, so you never output an empty logo field.
sameAs links with your real profiles, or remove the lines.Paste your homepage URL into the Rich Results Test or validator.schema.org. You should see an Organization and a WebSite with no errors.