How to use Google’s Organisation Logo markup with WordPress Theme Logo

The Organisation Logo markup allows web designers to specify their website’s preferred company logo to use in Google searches. For example, a business whose homepage is can add the following html markup to display the logo on a web page whilst providing Google with the appropriate markup:

<div itemscope itemtype="">
<a itemprop="url" href="">
<img itemprop="logo" src="" alt="Company name" />

In this guide we’re going to use WordPress’ Theme Logo feature to generate the image and url part of the code. First you need to make your theme supports ‘custom-logo’. Add the following to your functions.php:

function mytheme_setup() {
add_action('after_setup_theme', 'mytheme_setup');
view raw function.php hosted with ❤ by GitHub

Then add the following to your header.php where you want your logo to go

<div itemscope itemtype="">
<?php if ( function_exists( 'the_custom_logo' ) ) {
} ?>

This will output html code similar to this:

<div itemscope itemtype="">
<a href="" class="custom-logo-link" rel="home" itemprop="url" tabindex="0">
<img width="249" height="56" src="" class="custom-logo" alt="The Wireless Guy logo" itemprop="logo">

Notice that the_custom_logo() function automatically adds the correct itemprop tags. You don’t have to use a div tag to wrap the image and link. You can use any html tag you like as long as it contains itemscope itemtype= inside it.