Quick Win: Add JSON-LD Organization data to your WordPress website

Posted in
Structured data is important for your website. It helps search engines to get a better understanding of your content. If you don’t know what I’m talking about, just grab this JSON-LD code Organization snippet and add it to your website for a quick win.

We’re using the JSON-LD markup. JSON-LD is the Google recommended format for adding structured data to your website. Adding this snippet gives Google and other search engines a lot of information about your Company or Organization. The data you add to it may or may not appear in the results of particular searches.

The JSON-LD code snippet

Add this code to your functions.php file that’s located in the root of your child theme:

add_action( 'wp_head', 'render_json_ld_organization' );
function render_json_ld_organization() {
    ?>
    <script type="application/ld+json">     
    {
        "@context": "http://schema.org",
        "@type": "Organization",
        "url": "https://www.webmatic.be",
        "logo": "<?php echo get_stylesheet_directory(); ?>/assets/images/logo-webmatic.png",
        "contactPoint": [{
            "@type": "ContactPoint",
            "telephone": "+32-484-596-744",
            "contactType": "customer service",
            "availableLanguage": ["Dutch", "English"]
        }],
        "sameAs": [
            "https://www.facebook.com/webmaticdesigns",
            "https://in.linkedin.com/company/webmaticdesign",
            "https://plus.google.com/b/105299632303296666595",
            "https://www.pinterest.com/webmaticdesign",
            "https://twitter.com/webmaticdesign"]}
    </script>
    <?php
};

Be sure to edit this code to reflect your own data.

JSON-LD can be added to the head or body of your web page. I chose to add it in the head of every page.

And now look at all the stuff you just added to each and every page of your website: your point of contact, your phone number, your logo, your social profiles and more.

You can leave some structured data out or add other structured data to this code. More info can be found on the Google Support pages.

Now go and test your code in the Google Structured Data Testing Tool. This will point you to any errors you may have with your implementation.

That’s it, you should be good to go.

What is structured data?

This is a definition by Google:

Structured data is a standardized format for providing information about a page and classifying the page content; for example, if is it a recipe page, what are the ingredients, the cooking time and temperature, the calories and so on.

There are several possible formats you could use when adding structured data to your website:

  • JSON-LD: JavaScript notation embedded in a <script> tag in het page head or body.
  • Microdata: uses HTML tag attributes to add your specific properties.
  • RDFa: uses HMTL tag attributes too. It stands for ‘Resource Description Framework in Attributes’ and is recommended by W3C

The easiest way of implementing structured data is by using the JSON-LD format. It’s quick and easy to implement.

Google, currently the most popular search engine in the world, heavily promotes the use of JSON-LD structured data.

Koen Adams

Coding has always been fun to me. There's a lot to learn and after all those years I'm still learning a lot in my quest to be a great full stack developer in the WordPress space.
Posted in

Reader Interactions

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *