Question:
I recently got a comment from James asking if there is any way to add Structured data to the Divi theme without using any plugin so I decided to answer his question with this tutorial ( that Including a bonus child theme) [ excited 🙂 ] .
In this tutorial, I have three ways for you:
- I will first explain the whole code and its output source.
- I have also made a child theme out of it which you can download at the end of this article.
- What to do if you are already using a child theme or you don’t want to use the child theme.
If you are wondering what structured data is, then you should read this article first and then come back to this tutorial for the proper understanding.
Let’s take a dive into the code:
This code has integrated WordPress functions and tags that will automatically get the data and display it in their respective JSON+LD tags…… except one part, the ImageObject of the Logo.
You must change the URL “https://ahmedkaludi.com/logo.jpg” with your own logo URL but make sure that the height of the logo is 60 pixels, that is required by the Google Structured Data.
Here is the full source code hosted on the Gist.
Of course, you need to having some development knowledge in order to implement this code properly.
But…
2. Divi Structured Data Child Theme
Yes, there is always a but!, If you don’t have enough development knowledge to understand this code or you are just lazy like me, then I have prepared a child theme with all the code integrated and tested with the Divi theme.
Download Divi Structured Child Theme
You can just install this theme to your WordPress site ( from Appearance > Themes > Add New > Upload ) and then activate it. Your WordPress site will have the structured data integrated automatically to your blog posts.
3. What if I’m already using a Child theme or don’t want to use a child theme?
In that case, you can paste the below code into your functions.php file of your child theme (or god forbid, ” to the parent theme”) and the structured data should be integrated into your Divi WordPress theme.
Over to you!
Obviously, I will need your feedback and suggestions on this. As well as some tips from your side that you can share with us. How do you leverage the structured data on your site? You can leave a comment or directly ask questions by emailing me on ahmed@ahmedkaludi.com
When copy/pasting the code into our functions/php (that is in a child theme) 😉 Does the ahmedkaludi_structured_data_output stay as ahmedkaludi…
Or does ahmedkaludi get replaced with our own site info?
Jason
Mile 22
Hey Jason,
There is no need to change the ahmedkaludi_structured_data_output in PHP. However, you can change it if you want, but if there are any other instances of that string in the code then you must change it as well.
Also, you need to replace the logo url with yours at this code: “url”: “https://ahmedkaludi.com/logo.jpg”,
Hope it helps,
Regards,
Ahmed
Many thanks Ahmed, worked fine here!
In structured data testing tool, I can see the difference!
Glad to hear that Roberto!
I think I must be missing something. I downloaded and installed the child theme, but now I’m not seeing where I go to make edits to the structured data. Could you just point me in the right direction? (I added it to my sandbox site… its just a site where I test new stuff as you’ll see when you view it.)
Hey David,
You don’t have to make any changes into the structured data fields.
After you have installed and activated, check the website url with Structured data testing tool which will test the schema and validate it: https://search.google.com/structured-data/testing-tool/u/0/
I hope it helps,
Regards,
Ahmed
Hi Ahmed,
Thanks for the detailed explanation, It did worked for me in my first. Also no error on Google Structured data testing tool..
Thanks
I’m so glad to hear that Makarand!
Regards,
Ahmed
I’m passing along these questions:
Am I missing something or does it label all posts as articles? I didn’t see anything to distinguish between blog post types and page post types.
There’s nothing in there to define the publisher either, which you’d need for pages.
I’m worried that this schema won’t validate or pass muster with Google. Even if it did validate, it’s undercutting the SEO because pages carry more weight as the publisher.
Hey DebG,
First of all, Thank you for such interesting questions.
At the moment, this will work only with the blog posts and not with pages, but it is very easy to add it in the pages as well. If you want, I can send the code in the next comment.
Actually, we do have a publisher tag in it. This code should validate because I’ve tested this on the Structured data testing tool.
But I would say that Pages doesn’t carry much weight as opposed to posts, both post types are same for Google. It is the content that matters to the Google.
Let me know if you want the code for adding it to the pages.
Regards,
Ahmed
Thank you, Ahmed, and yes, I would love to have the rest of the code
Thanks!
Deb
Hey DebG,
Try to use this code: https://gist.github.com/ahmedkaludi/84230ace176edde883aba9db38c6f931
Regards,
Ahmed