FUTIA
SEO9 min read

How to Add Schema.org JSON-LD to WordPress? Rank Math + Custom Code

Adding Schema markup to your WordPress site makes it easier for Google to understand your content. Automatic with Rank Math, full control with custom code: which works for you?

How to Add Schema.org JSON-LD to WordPress? Rank Math + Custom Code
Miraç Eroğlu
May 14, 2026

If you want search engines to fully understand your content on your WordPress site, you must add Schema.org markup. Google doesn't look at HTML to understand whether it's a recipe, article, product, or event—it looks at structured data. I've seen it over 6 years of providing SEO consulting to dozens of Turkish brands: sites that add Schema get rich snippets, those that don't remain as plain blue links. Right now at FUTIA, we're automatically adding Recipe schema to 618 recipe pages for italyanmutfagi.com, and Google is showing all of them as starred snippets. In this article, I'll show you two methods: quick setup with plugins like Rank Math and full control with custom JSON-LD code. Which one you choose depends on your site's structure and how much customization you want. You can use both on the same site—I do that on most projects.

What Are Schema.org and JSON-LD, and Why Should You Use Them in WordPress?

Schema.org is a standard created jointly by Google, Microsoft, Yahoo, and Yandex in 2011. The goal is simple: to label information on web pages in a way machines can understand. For example, you write "200 grams of flour" in a recipe post. Google sees this as normal text, but if you label it with Recipe schema as "recipeIngredient": "200 grams of flour", Google understands it's a recipe ingredient. JSON-LD (JavaScript Object Notation for Linked Data) is the cleanest method of adding this structured data to your page. You place data in JSON format within a <script type="application/ld+json"> tag in the <head> or <body> section of the page. Google reads this data and can display rich snippets.

Using Schema in WordPress has three major benefits. First, increased visibility in search results. When extra information like star ratings, price information, author photo, and publication date is displayed, click-through rate (CTR) can increase by 20-30%. Second, Google categorizes your content correctly. This is especially critical for time-sensitive content like news, events, and job postings. Third, the ability to appear in voice assistant and special search results. When someone asks "What concerts are in Istanbul today?", sites with Event schema stand out. After I added JobPosting schema to kamupersonelhaber.com, we started getting special card views in "public job postings" searches, and traffic increased by 40% within 3 weeks.

Alternatives to JSON-LD include Microdata and RDFa, but Google officially recommends JSON-LD. Because it doesn't mix with HTML, it exists as a separate script block. So it works independently of your theme without breaking your design. This is also the most practical method for WordPress.

Automatic Schema Addition with Rank Math (No-Code Method)

Rank Math is one of the most popular SEO plugins in WordPress and offers built-in Schema support. Most features that are in Yoast SEO's paid version are free in Rank Math. I've been using Rank Math since 2020 because Schema management is much more flexible. Installation is simple: from WordPress admin panel, go to Plugins > Add New > search for "Rank Math", install it, and follow the Setup Wizard. In the first step, connect your Google Search Console, then select your site type (blog, e-commerce, portfolio, etc.). The wizard will automatically add Organization or Person schema.

Rank Math's Schema module is enabled by default. You can check it from Rank Math > Dashboard > Schema Markup tab. Here there's a "Default Schema Type" option, you can generally leave it as "Article" or "BlogPosting". If you want to select a custom schema type for each post, go down to the Rank Math meta box in the post editor and click the "Schema" tab. There are over 20 schema types here: Article, Recipe, Product, Event, Course, FAQ, HowTo, Review, Video, LocalBusiness, JobPosting, and more. For example, if you're writing a recipe post, select "Recipe", and Rank Math will open fields for ingredients, cooking time, calories, star rating, etc. When you fill these in, Recipe schema will be automatically added to the <head> section of the page.

One advantage of Rank Math is that it offers FAQ and HowTo schemas as Gutenberg blocks. When you add an FAQ block to your post, it's displayed visually as an accordion on the page, and FAQPage schema is automatically created. Google can display these FAQs as an expandable list in search results. I added FAQ blocks to product pages on diolivo.com.tr, and the site got direct answer snippets for questions like "how to store olive oil", traffic increased by 15%.

Rank Math has its limitations too. For example, if you want to use a very specific Schema type (like SoftwareApplication, MedicalCondition, Dataset), there may not be ready-made fields in Rank Math. Also, programmatically injecting different Schema values to thousands of pages is difficult. Rank Math has an API but the documentation is weak. In this case, custom code is needed.

Manual Schema Addition with Custom JSON-LD Code

If you want full control, you can inject JSON-LD code directly into WordPress. This method is critical especially in programmatic SEO projects or when using non-standard Schema types. I mostly use custom code in FUTIA projects because I need to pull data from APIs and create dynamic Schema. For example, on doktorbul.com, we create Physician schema for each of 79,000 doctor profiles, rendering JSON-LD with information pulled from the database (specialty, hospital they work at, graduation year).

The first step is to decide which type to use on Schema.org. Go to the schema.org site and type "Recipe" or "Article" in the search box. On each Schema type's page, you'll see which properties are required and which are recommended. For example, for Recipe, required: name, image. Recommended: author, datePublished, description, prepTime, cookTime, recipeIngredient, recipeInstructions, aggregateRating. You can paste the code into Google's Rich Results Test tool (search.google.com/test/rich-results) and test it.

There are three ways to add JSON-LD code to WordPress. First, adding it to your theme's functions.php file with wp_head or wp_footer hook. Second, using a plugin like Code Snippets (safer, code doesn't get lost in theme updates). Third, writing a custom plugin (my preference for large projects). Let me show you the Code Snippets method, it's the most practical.

Install the Code Snippets plugin (free). Click Snippets > Add New. Title: "Custom Article Schema". Select "PHP" as code type. Paste the following code:

function futia_add_article_schema() {
    if (is_single()) {
        global $post;
        $schema = array(
            '@context' => 'https://schema.org',
            '@type' => 'Article',
            'headline' => get_the_title(),
            'image' => get_the_post_thumbnail_url($post->ID, 'full'),
            'datePublished' => get_the_date('c'),
            'dateModified' => get_the_modified_date('c'),
            'author' => array(
                '@type' => 'Person',
                'name' => get_the_author(),
                'url' => get_author_posts_url(get_the_author_meta('ID'))
            ),
            'publisher' => array(
                '@type' => 'Organization',
                'name' => get_bloginfo('name'),
                'logo' => array(
                    '@type' => 'ImageObject',
                    'url' => 'https://futia.io/logo.png'
                )
            ),
            'description' => get_the_excerpt()
        );
        echo '<script type="application/ld+json">' . json_encode($schema, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . '</script>';
    }
}
add_action('wp_head', 'futia_add_article_schema');

This code adds Article schema to every single post page (is_single). Don't forget to use the JSON_UNESCAPED_UNICODE flag in the json_encode function, otherwise Turkish characters will be encoded like \u00e7. Save and activate the code, then view the source code of any post on your site (Ctrl+U), you'll see the JSON-LD block inside <head>. Paste the URL into Rich Results Test to validate.

For more complex scenarios, you can add different Schema types based on custom post types. For example, Event schema for an "event" post type:

if (get_post_type() === 'etkinlik') {
    $schema = array(
        '@context' => 'https://schema.org',
        '@type' => 'Event',
        'name' => get_the_title(),
        'startDate' => get_post_meta($post->ID, 'etkinlik_tarihi', true),
        'location' => array(
            '@type' => 'Place',
            'name' => get_post_meta($post->ID, 'mekan_adi', true),
            'address' => get_post_meta($post->ID, 'mekan_adres', true)
        ),
        'image' => get_the_post_thumbnail_url($post->ID, 'full'),
        'description' => get_the_excerpt()
    );
}

Here we're pulling date and venue information from custom fields with get_post_meta. If you're using Advanced Custom Fields (ACF), you'd pull it like get_field('etkinlik_tarihi'). On italyanmutfagi.com, I store recipe ingredients as an array with ACF and convert them to a recipeIngredient array in JSON-LD.

Using Rank Math and Custom Code Together (Hybrid Approach)

On many projects, I use Rank Math for basic Schemas (Article, Organization, BreadcrumbList) and custom code for specific needs. For example, on memuratamalari.com, I left Rank Math's Article schema as default, but added JobPosting schema to job posting pages with custom code. Rank Math doesn't support JobPosting, so we wrote our own code. We pull job posting details from the ilan.gov.tr API and create dynamic JobPosting schema for each posting. Result: we got listed on Google for Jobs, organic traffic reached 40,400/month.

The point to watch out for in the hybrid approach: don't add the same Schema type twice. For example, if Rank Math is already adding Article schema, don't add another Article with custom code. When Google sees duplicate schema, it can get confused. Instead, disable Schema for that page in Rank Math (there's a "Disable Schema" option in the post editor under Rank Math > Schema) or do an if (!function_exists('rank_math')) check in custom code.

Another strategy is to use Rank Math for global Schemas (Organization, WebSite, BreadcrumbList) and custom code for page-based Schemas (Recipe, Product, Event). Organization schema is generally the same across all sites, you set it once in Rank Math (Rank Math > Schema > Organization tab), it's automatically added to every page. But Recipe schema contains different ingredients and time for each recipe, you create that dynamically with custom code.

At FUTIA, I recommend this template to clients: Rank Math + WooCommerce integration for e-commerce sites (Product schema automatic), Rank Math + custom FAQ/HowTo blocks for blog sites, completely custom code for content portals (because data comes from APIs). On diolivo.com.tr, Rank Math handles WooCommerce Product schema, but we wrote custom code to add special Offer schema to cart abandonment emails.

Common Mistakes and Schema Validation

The most common mistakes I encounter when adding Schema: leaving required fields empty, using wrong data type (for example, date should be in ISO 8601 format instead of string), broken image URL, if aggregateRating is added, ratingCount being 0 (Google requires minimum 1). You can see Schema errors in the "Enhancements" section of Google Search Console. For example, if you get a "Missing field 'image'" warning, you need to add a featured image to every post.

Use Rich Results Test (search.google.com/test/rich-results) and Schema Markup Validator (validator.schema.org). The first is Google's own tool, showing which rich results can appear. The second is Schema.org's official validator, catching syntax errors. I always test in both tools after adding any new Schema type. For example, when testing Recipe schemas on italyanmutfagi.com, we had given the "recipeInstructions" field as a string, but Google expects a HowToStep array. After fixing it, rich snippets started appearing.

Another common mistake is rendering Schema with JavaScript. If you're making a single-page application with React or Vue, if you render Schema client-side, Google may not see it. Use server-side rendering (SSR) or pre-rendering. This problem generally doesn't exist in WordPress because PHP runs server-side. But be careful with modern stacks like headless WordPress + Next.js. I made futia.net with Next.js, creating Schemas inside getStaticProps and putting them in the <Head> component.

Some Schema types (like Review, AggregateRating) carry risk of abuse. If you give your own product 5 stars and add Review schema, Google can mark it as "self-serving review" and remove rich results. Read Google's Spam Policies. I recommend clients add real user reviews to Schema, never fake ratings.

Schema Automation in Programmatic SEO

One of FUTIA's areas of expertise is programmatic SEO, meaning automatically creating thousands of pages and adding custom Schema to each one. On doktorbul.com, there are 79,000 doctor profiles, we create Physician schema for each one. The database has the doctor's name, photo, specialty, hospital they work at, contact information. We pull this information with PHP and convert it to JSON-LD. The page template looks like this:

$doktor = get_doktor_data($doktor_id); // Pull from database
$schema = array(
    '@context' => 'https://schema.org',
    '@type' => 'Physician',
    'name' => $doktor['ad_soyad'],
    'image' => $doktor['foto_url'],
    'medicalSpecialty' => $doktor['uzmanlik'],
    'worksFor' => array(
        '@type' => 'Hospital',
        'name' => $doktor['hastane_adi']
    ),
    'address' => array(
        '@type' => 'PostalAddress',
        'addressLocality' => $doktor['sehir']
    )
);
echo '<script type="application/ld+json">' . json_encode($schema) . '</script>';

With this approach, every doctor page gets a rich snippet on Google like "Dr. X, Cardiology Specialist, Y Hospital". When a user searches for "istanbul cardiologist", thanks to Schema, Google knows which doctors are in Istanbul and highlights them.

On italyanmutfagi.com, there are 618 recipe pages, all automatically created. Recipe schema for each recipe, ingredients and instructions come from the database. We also add aggregateRating (user votes are real, pulled from Disqus comments). Result: starred snippet in "mushroom risotto recipe" search, click-through rate increased by 35%.

When doing Schema automation in programmatic SEO, pay attention to data quality. If missing or incorrect data reflects in Schema, Google won't trust it. I always put fallback values. For example, if there's no recipe photo, placeholder image URL; if cooking time isn't entered, "PT30M" (30 minutes) default value. But if you use too many defaults, the Schema loses its meaning. Don't let data quality drop below 80%.

Schema Automation Service with FUTIA

I'm Miraç, founder of FUTIA. I have 6 years of social media marketing experience, 2 years of AI automation experience, and I'm a Hacettepe graduate. I work from the Netherlands but provide special service to Turkish brands: site + automation + monthly maintenance package. I have deep experience with Schema.org because all FUTIA projects involve programmatic SEO. I've created dynamic Schema for thousands of pages in live projects like doktorbul.com, italyanmutfagi.com, kamupersonelhaber.com, memuratamalari.com, diolivo.com.tr. We don't just add Schema, we also offer solutions like API integration, content automation, text generation with Claude Haiku, CartBouncy cart recovery.

If you want to add Schema to your WordPress site but don't have technical knowledge, or if you want to programmatically inject Schema to thousands of pages, contact me. WhatsApp: +90 532 491 17 05 (you can message directly, I usually respond within 2-3 hours). Email: info@futia.net. Website: https://futia.io, you can read my blog posts: https://futia.io/blog. First 30 minutes of consultation is free, I'll analyze your site and tell you which Schema types will work for you. FUTIA's difference is that we offer not just installation, but monthly maintenance and continuous optimization. Schemas change according to Google's requirements, we keep you up to date.

Frequently Asked Questions

Is there a difference between Rank Math and Yoast SEO's Schema support?

Yes, there are significant differences. Rank Math has over 20 Schema types available in the free version (Recipe, Event, Product, Course, FAQ, HowTo, etc.), while in Yoast SEO these features are mostly in the Premium version. Rank Math's Schema editor is more flexible, you can select different Schema types for each post and fill in custom fields. Yoast is simpler but more limited. I've been using Rank Math since 2020, especially the FAQ and HowTo blocks are very functional. Also, Rank Math's Google Search Console integration is better, you can see Schema errors directly in the panel.

Should I use functions.php or a plugin when adding custom JSON-LD code?

I strongly recommend using a plugin, especially a free one like Code Snippets. If you add code to functions.php, your code will be deleted when you update the theme (if you're not using a child theme). With Code Snippets, your codes are stored in the database and work independently of the theme. You can also activate/deactivate codes, and they automatically disable in case of errors. For large-scale customizations in FUTIA projects, I write custom plugins, but Code Snippets is sufficient for small tasks. The only downside is that if you add too many snippets, management can become difficult, then a custom plugin makes more sense.

When will rich results appear on Google after adding Schema?

There's no guaranteed timeframe, but generally between 1-4 weeks. After adding Schema, manually submitting the URL for indexing in Google Search Console (URL Inspection > Request Indexing) can speed up the process. After Google sees the Schema, it decides whether to show rich results based on your site's authority, content quality, and user signals. If there's low-quality content or spam suspicion, it won't give rich snippets even with Schema. On italyanmutfagi.com, starred snippets started appearing 2 weeks after I added Recipe schemas. Be patient, but if it still doesn't appear after 1 month, check for errors with Rich Results Test or check the Enhancements report in Google Search Console.

Can I use multiple Schema types on the same page?

Yes, and it's often recommended. For example, a recipe post can have both Article and Recipe schema. Or an event page can have Event + BreadcrumbList + Organization schemas together. Google supports multiple Schema types on the same page, and in some cases (like FAQ + Article) can show both in rich results. What's important is that each Schema is in its own JSON-LD block or you use a @graph array within a single block. I generally add them as separate blocks, it's cleaner. But don't add the same type of Schema twice (like two Articles), you'll get a duplicate error.

Should Product schema be added with Rank Math or WooCommerce on an e-commerce site?

WooCommerce already adds Product schema, but at a very basic level (name, price, image). Rank Math's WooCommerce integration is richer: it automatically fills fields like aggregateRating, review, availability, brand, sku. I used the Rank Math + WooCommerce combination on diolivo.com.tr, detailed Product schema was added to product pages, we got listed on Google Shopping. For settings, go to Rank Math > WooCommerce tab, activate the "Add Product Schema" option. If you have very specific needs (like dynamic price updates, stock status coming from API), you can override Schema with custom code using WooCommerce hooks. Check out the woocommerce_structured_data_product hook.

ABOUT THE AUTHOR
Miraç Eroğlu

Hacettepe mezunu, 6 yıldır sosyal medya, 2 yıldır AI otomasyon.

Learn more →

Want to apply one of the techniques from this post? Fill out a short form and we'll email you a free preview audit within 48 hours.