Organization Structured Data
Outputs Organization schema (JSON-LD) on the homepage with your site name, URL, logo and social profiles, helping search engines understand who runs the site.
Opens WPIDE on
Code
add_action( 'wp_head', function () {
if ( ! is_front_page() ) {
return;
}
$data = array(
'@context' => 'https://schema.org',
'@type' => 'Organization',
'name' => get_bloginfo( 'name' ),
'url' => home_url( '/' ),
);
$logo_id = (int) get_theme_mod( 'custom_logo' );
$logo = $logo_id ? wp_get_attachment_image_url( $logo_id, 'full' ) : '';
if ( $logo ) {
$data['logo'] = $logo;
}
// Social profile URLs, for example 'https://www.linkedin.com/company/your-company'.
$profiles = array();
if ( $profiles ) {
$data['sameAs'] = array_values( $profiles );
}
echo '<script type="application/ld+json">' . wp_json_encode( $data, JSON_UNESCAPED_SLASHES | JSON_HEX_TAG ) . "</script>\n";
} );
Notes
Add your social profile URLs to $profiles. Change @type to LocalBusiness or another type if it fits better.
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.