Why Add Schema Without a Plugin?

WordPress plugins for schema markup like Rank Math and Yoast are excellent tools, but they're not always the right choice. Here's when going plugin-free makes sense:

  • You want full control over exactly what schema is added and where
  • Your site is performance-focused and every plugin adds overhead
  • You only need schema on specific pages, not sitewide
  • You're using a headless or custom WordPress setup where plugins may interfere
  • You already have a lean plugin stack and want to keep it that way
â„šī¸
Before you start: Generate your JSON-LD schema using one of Schemify's free generators, then come back here to add it to WordPress. The methods below assume you already have your schema code ready to paste.

Generate your schema first

15+ free JSON-LD generators, no signup required

Browse All Generators →

3 Methods: Which Should You Use?

There are three main ways to add schema markup to WordPress without a plugin. Each suits a different situation:

Method Best For Survives Updates Difficulty
Method 1: functions.phpSitewide schema (all pages)✅ Yes (child theme)Intermediate
Method 2: header.phpSitewide schema (all pages)❌ No (theme updates)Beginner
Method 3: Block EditorPer-page / per-post schema✅ YesBeginner
âš ī¸
Always use a child theme when editing theme files. If you edit your parent theme directly, your changes will be lost every time the theme updates. Create a child theme first if you haven't already.

Method 1: Using functions.php (Recommended)

This is the most robust method for adding schema sitewide. It uses WordPress's wp_head action hook to inject your schema into every page's head tag automatically.

1
Access your child theme's functions.php
  1. Log in to your WordPress Admin
  2. Go to Appearance → Theme File Editor
  3. In the right panel, select your child theme
  4. Click on functions.php
2
Add your schema using wp_head hook

Scroll to the bottom of functions.php and paste this code. Replace the schema inside the heredoc with your own generated JSON-LD:

functions.php — Sitewide Schema
add_action( 'wp_head', 'schemify_add_schema_markup' );
function schemify_add_schema_markup() {
  echo '<script type="application/ld+json">';
  echo '{
    "@context": "https://schema.org",
    "@type": "WebSite",
    "name": "Your Site Name",
    "url": "https://yoursite.com"
  }';
  echo '</script>';
}

Click Update File to save. Your schema is now added to every page on your site.

3
Add page-specific schema conditionally

You can add different schema to different pages using WordPress conditional tags like is_single(), is_page(), and is_home():

functions.php — Conditional Schema
add_action( 'wp_head', 'schemify_conditional_schema' );
function schemify_conditional_schema() {

  // Add LocalBusiness schema on homepage only
  if ( is_front_page() ) {
    echo '<script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "LocalBusiness",
      "name": "Your Business",
      "url": "https://yoursite.com"
    }
    </script>';
  }

  // Add Article schema on single blog posts
  if ( is_single() ) {
    $title = get_the_title();
    $date  = get_the_date( 'Y-m-d' );
    $url   = get_permalink();
    echo "<script type='application/ld+json'>
    {
      \"@context\": \"https://schema.org\",
      \"@type\": \"BlogPosting\",
      \"headline\": \"{$title}\",
      \"datePublished\": \"{$date}\",
      \"url\": \"{$url}\",
      \"author\": {\"@type\": \"Organization\", \"name\": \"Schemify\"}
    }
    </script>";
  }

}

Method 2: Editing header.php

This is the simplest method: you paste your schema directly into your theme's header template file. The downside is that it gets overwritten when your theme updates, so always use a child theme.

1
Open header.php in Theme Editor
  1. Go to Appearance → Theme File Editor
  2. Select your child theme from the dropdown
  3. Click header.php in the right sidebar
  4. If header.php doesn't exist in your child theme, create it by copying from the parent theme
2
Paste schema before </head>

Find the closing </head> tag in header.php and paste your JSON-LD immediately before it:

header.php — Where to paste
  <!-- Other head tags above -->

  <!-- Paste your schema here -->
  <script type="application/ld+json">
  {
    "@context": "https://schema.org",
    "@type": "WebSite",
    "name": "Your Site Name",
    "url": "https://yoursite.com"
  }
  </script>

  <?php wp_head(); ?>
</head>

Click Update File to save.

Method 3: Block Editor (Per-Page Schema)

This is the easiest method for adding schema to individual posts or pages without touching any theme files. It uses the Custom HTML block in WordPress's block editor (Gutenberg).

💡
Best use case: Use this method when you need different schema on different pages, for example, FAQPage schema on your FAQ page, Product schema on your product pages, and Recipe schema on recipe posts.
1
Open your post or page in the block editor
  1. Go to Posts or Pages in WordPress admin
  2. Click Edit on the post or page you want to add schema to
  3. The block editor will open
2
Add a Custom HTML block
  1. Click the + Add Block button
  2. Search for "Custom HTML"
  3. Click to add the Custom HTML block
  4. Place it anywhere on the page; the schema is invisible to visitors
3
Paste your JSON-LD into the block

Paste your complete JSON-LD schema, including the script tags, directly into the Custom HTML block:

Custom HTML Block — FAQ Schema Example
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "mainEntity": [
    {
      "@type": "Question",
      "name": "Your question here?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "Your answer here."
      }
    }
  ]
}
</script>

Click Update or Publish to save. Your schema is now live on that specific page only.

Step 4: Validate Your Schema

After adding your schema to WordPress, always validate it before considering the job done. Use both tools:

1
Validate with Schemify Validator

Go to the Schemify Schema Validator, paste your JSON-LD code, and click Validate. The tool checks your JSON syntax, identifies your schema type, and highlights any missing required fields all instantly without needing a live URL.

2
Test with Google's Rich Results Test

Once your page is live, go to Google's Rich Results Test and paste your page URL. Google will confirm whether your schema is valid and whether it qualifies for rich results. Any errors shown here need to be fixed before Google will display rich results for your page.

3
Monitor in Google Search Console

In Google Search Console, go to the Enhancements section in the left sidebar. Here you'll see reports for each rich result type detected on your site, including any errors, warnings, or valid items. This is your ongoing monitoring dashboard for schema performance.

Common Mistakes to Avoid

  • Editing the parent theme directly: Always use a child theme. Parent theme edits are lost on every theme update.
  • Forgetting to escape quotes in PHP: When using the echo method in functions.php, use single quotes for the outer string and escape any double quotes inside the JSON with backslash: \"
  • Adding schema in the body instead of the head: JSON-LD should go in the <head> tag. The custom HTML block method is an exception. Google can read JSON-LD from the body too, but head placement is best practice.
  • Not validating after adding: A small PHP syntax error can break your entire site. Always validate in a staging environment first if possible.
  • Using the same schema on every page: Don't add FAQPage schema sitewide; only add it to pages that actually have FAQ content. Mismatched schema is a Google policy violation.
💡
Staging tip: Before editing live theme files, test your changes on a staging site or use a WordPress staging plugin. A syntax error in functions.php can cause a white screen of death on your live site.

Frequently Asked Questions

Yes. You can add JSON-LD schema markup to WordPress without any plugin using three methods: editing your child theme's functions.php, editing header.php, or using the Custom HTML block in the block editor. All three methods are fully supported by Google.
Using a child theme's functions.php with the wp_head hook is the safest and most maintainable method. It survives theme updates, keeps your schema code organized in one place, and gives you full control over when and where schema is added using conditional tags.
No. JSON-LD schema markup is a tiny text snippet typically under 1KB added to your page head. It adds virtually no load time and has zero measurable impact on page speed scores. In fact, adding schema without a plugin avoids the performance overhead that schema plugins can add through their CSS and JavaScript files.
The easiest method is using the Custom HTML block in the block editor; you add schema directly to each post or page individually. For a more automated approach, use conditional tags in functions. PHP (is_single(), is_page(), is_front_page()) to output different schema based on the page type being viewed.
A PHP syntax error in functions.php can cause a white screen of death. If this happens, connect to your site via FTP or file manager in cPanel, navigate to your child theme folder, and edit functions.php to fix or remove the error. Always back up functions.php before making changes, and test on a staging site first if possible.

Related Tools