Skip to main content
Start free trial

Checklist

How to Add JSON-LD to WordPress, Plugin or Code

How to add JSON-LD schema to WordPress in 7 steps, with an SEO plugin or by hand, without duplicating your SEO plugin's graph or confusing AI assistants.

By Jenny BeasleyUpdated October 21, 202610 min read

Adding JSON-LD to WordPress: an AI bot slots a card of nested structured data into the top of a web page

AI summary

WordPress sites usually get JSON-LD from an SEO plugin such as Yoast SEO or Rank Math, and the most common mistake is a second schema block that contradicts that plugin's graph. JSON-LD helps AI assistants and Google confirm what a business and a page are, as long as it matches the visible page. In LovedByAI's Lab data (pages optimized March to June 2026), pages with an FAQ block in FAQPage markup beat comparable pages on 79% of sites.

When someone asks ChatGPT or Perplexity for "a family dentist in Austin who takes emergencies", the assistant has to work out from your pages what your business is, where it is and what it does. On many WordPress sites those facts are scattered: the name in a logo image, the address in the footer, the services across six pages with no labels.

JSON-LD states those facts in one structured block. Google recommends JSON-LD as the format for structured data, and it is the format most WordPress SEO plugins already write. We build LovedByAI, an AI search optimization platform for small businesses. It does the on-page work that helps ChatGPT, Google's AI Overviews and Perplexity read, cite and recommend a business's website, then reports the AI mentions and AI referral visits that follow. Adding schema without breaking the SEO plugin's output is a large part of that work. These are the seven steps, with and without a plugin.

Step 1: Check what JSON-LD schema your WordPress site already has

Find out what is already on the site before adding anything. Most WordPress SEO plugins and many themes add some schema automatically.

Run your homepage, your main service page and your contact page through two free tools:

  1. Google's Rich Results Test lists the schema types Google detects. Look for LocalBusiness, Service and FAQPage. If you only see Organization, WebSite and BreadcrumbList, there is work to do.
  2. The Schema Markup Validator checks everything against the full Schema.org vocabulary, including types Google does not use for rich results.

This is what a WordPress site with no structured data looks like in the Rich Results Test. The site is our own Northbridge Law Group demo on WordPress.com, tested on 21 October 2026:

Google Rich Results Test for a WordPress demo law firm site showing No items detected, meaning the homepage has no JSON-LD
Google Rich Results Test for a WordPress demo law firm site showing No items detected, meaning the homepage has no JSON-LD

Note which plugin or theme produced each block. You will need that in step 3, because the most common WordPress schema problem is two sources describing the same business differently.

Step 2: Pick the schema types for your business: LocalBusiness, Service and FAQPage

Schema.org has hundreds of types, but a small business needs three.

LocalBusiness, or a more specific subtype

LocalBusiness says what kind of business you are and where you operate. Use the most specific subtype that fits: LegalService for a law firm, Dentist for a dental practice, RealEstateAgent for a realtor. Our LocalBusiness schema guide covers the fields and the plugins.

Service

Add one Service for each distinct service. "Personal injury law" and "estate planning" are separate services, not one "legal services" label. Our Service schema guide has worked examples.

FAQPage

Mark up the three to five questions clients ask before hiring you, with the answers visible on the page. Google stopped showing FAQ rich results on 7 May 2026, so the value now is for AI assistants reading the page. In LovedByAI's optimization leaderboard, pages that got a visible FAQ block mirrored in FAQPage markup earned more AI referral visits than comparable pages on the same site on 79% of sites (pages first optimized 1 March to 11 June 2026, 90 days each). That is an association, not a controlled test.

Step 3: Choose how to add JSON-LD to WordPress: plugin, code or custom fields

Pick the route that matches your comfort level and the plugins you already run.

Option A: an SEO plugin (best for most sites)

Yoast SEO, Rank Math and AIOSEO all write JSON-LD from their settings. Set the site type (organization or person), the business details and the default schema per post type, then adjust page by page. Rank Math and AIOSEO offer more schema types in their editors; Yoast keeps a single connected graph and leaves extra types to add-ons or code.

LovedByAI adds Organization and FAQPage JSON-LD and merges it into the schema your SEO plugin already outputs, so you do not end up with two competing blocks. It also writes the visible FAQ section the FAQPage markup describes.

Option B: add JSON-LD with code, without a plugin

If you are comfortable editing a child theme, print the markup through the wp_head hook and limit it to the pages it describes:

function lba_local_business_schema() {
    if ( ! is_front_page() && ! is_page( 'contact' ) ) {
        return;
    }
    $schema = array(
        '@context'   => 'https://schema.org',
        '@type'      => 'Dentist',
        '@id'        => home_url( '/#business' ),
        'name'       => 'Bright Smile Dental',
        'description'=> 'Family and cosmetic dentistry in Austin, TX. Same-day emergency appointments.',
        'telephone'  => '+15125551234',
        'url'        => home_url( '/' ),
        'address'    => array(
            '@type'           => 'PostalAddress',
            'streetAddress'   => '456 Oak Avenue',
            'addressLocality' => 'Austin',
            'addressRegion'   => 'TX',
            'postalCode'      => '78701',
            'addressCountry'  => 'US',
        ),
        'areaServed' => array( '@type' => 'City', 'name' => 'Austin' ),
    );
    echo '<script type="application/ld+json">' . wp_json_encode( $schema, JSON_UNESCAPED_SLASHES ) . '</script>';
}
add_action( 'wp_head', 'lba_local_business_schema' );

Use a child theme or a code snippets plugin so the change survives theme updates. If an SEO plugin is active, read the next section first.

Option C: Advanced Custom Fields for agencies

Store schema properties in custom fields and build the JSON-LD from them in a template. It is the most flexible route and the most work, and it suits agencies running many client sites from one theme.

How to avoid duplicate JSON-LD from Yoast, Rank Math and other plugins

A second, separate block that describes the business again is the most common WordPress schema mistake, and one WordPress developers raise again and again on forums. Two LocalBusiness blocks with different names, addresses or opening hours give a parser two answers to one question.

Extend your SEO plugin's graph instead of adding beside it:

  • Yoast SEO exposes the wpseo_schema_graph_pieces filter, which adds a custom piece to Yoast's single graph. The Yoast schema API documentation has examples.
  • Rank Math exposes the rank_math/json_ld filter, which lets you add, change or remove entries in its output.
  • If you use a dedicated schema plugin, switch off the overlapping types in the SEO plugin (or the other way round), so only one source describes each thing.

After any change, run the Rich Results Test again and count the blocks for each type.

Step 4: Write the business description in your schema for AI

The description field is not marketing copy. It is a factual statement an assistant may lift into an answer, so be specific.

A weak description reads "We provide legal services." A strong one reads "Personal injury law firm in Dallas, TX. Handles car accident, slip-and-fall and workplace injury cases. Free consultations."

The pattern is what you are, where you are, what you specifically do, and one practical detail that makes you easy to choose. Keep it consistent with the description on your Google Business Profile.

Step 5: Add the right JSON-LD to each WordPress page

Different pages carry different schema. Do not put everything on the homepage.

PageSchema to add
HomepageLocalBusiness (or Organization) with full business details
Each service pageService, describing that one service and linked to the business
Contact pageLocalBusiness, referencing the same business by its @id
Pages with an FAQ sectionFAQPage, matching the questions shown on the page
Blog postsArticle or BlogPosting (SEO plugins handle this)

The markup must describe what is visible on the page. Google's structured data guidelines say so, and schema that says Austin on a page that says Dallas helps nobody.

Step 6: Validate your WordPress JSON-LD

Test every page you changed.

  1. Google's Rich Results Test: confirm the types appear with no errors.
  2. The Schema Markup Validator: catches problems the Google tool ignores.
  3. The page source: search for application/ld+json to confirm the script renders. Some caching and minification plugins strip or break script tags.

Here is the LegalService block for the same demo firm in the Schema Markup Validator: one LegalService entity, its address and service area parsed, 0 errors and 0 warnings.

Schema Markup Validator showing a LegalService JSON-LD block for a WordPress law firm site with 0 errors and 0 warnings
Schema Markup Validator showing a LegalService JSON-LD block for a WordPress law firm site with 0 errors and 0 warnings

Watch for missing required fields, an Organization where you meant LocalBusiness, and duplicate blocks for the same type.

Step 7: Keep your schema in step with your site

Schema goes stale when the business changes and nobody updates it.

  • Each quarter, check that the address, phone number, opening hours and service list in your schema still match the site.
  • After a theme switch, a new plugin or a big page edit, rerun the Rich Results Test on the affected pages.
  • Ask ChatGPT or Perplexity "What does [your business name] do?" and compare the answer with your schema. A wrong answer usually points to a page or profile that disagrees with the others.

Three mistakes that undo WordPress schema work

  1. Blocking AI crawlers. If robots.txt or your firewall turns away OAI-SearchBot, ChatGPT-User, PerplexityBot or Claude-SearchBot, those assistants never read the page or its schema. In our 314-site crawler study, 43% of sites refused at least one AI crawler in August 2026, often at the server with nothing in robots.txt.
  2. Schema that contradicts the page. If the markup says "personal injury attorney" and the headline says "full-service law firm", fix one so they agree.
  3. Generic schema only. Organization alone says little. A specific LocalBusiness subtype, real Service descriptions and a visible FAQ give an assistant facts to work with.

Adding JSON-LD to WordPress yourself or with a plugin: next steps

To do it yourself, start with step 1: run the Rich Results Test on your homepage now. Most WordPress sites have gaps you can fix in an afternoon.

To have it done for you, the LovedByAI plugin adds Organization and FAQPage schema merged into your SEO plugin's graph, writes the visible FAQ sections, rewrites headings as the questions customers ask, and reports AI crawler visits and AI referral traffic. The free GEO checker shows what an AI crawler sees on any page in about a minute. For the full on-page list beyond schema, see the GEO checklist.

Jenny Beasley

Jenny Beasley is Head of AI Search Optimization at LovedByAI. She spent seven years at IBM, the last three as Director of SEO, then nearly three years consulting on SEO and LLM readiness for B2B tech companies. She developed the GEO framework behind the plugin, which earned optimized pages 11 times the AI referral visits of untouched pages across a 116-site study.

FAQ: How to Add JSON-LD to WordPress, Plugin or Code

Do I need to know how to code to add JSON-LD to WordPress?

You do not need to code to add JSON-LD to WordPress. Yoast SEO, Rank Math and AIOSEO generate JSON-LD from their settings pages: you fill in your business name, address and page types, and the plugin writes the markup. Code is only needed for schema types your plugin does not support.

How do I add schema markup to WordPress without a plugin?

Add a function to a child theme's functions.php (or a code snippets plugin) that prints a script tag of type application/ld+json in the page head through the wp_head hook, limited to the pages it describes. Keep the markup in step with the visible page, and check that it does not duplicate what your SEO plugin already outputs.

Where does JSON-LD go on a WordPress page?

JSON-LD goes in a script tag of type application/ld+json, usually in the page head. Google also reads it in the body. WordPress plugins and themes add it through the wp_head hook, which is why you will not see it in the block editor, only in the page source.

How do I check if my WordPress site has schema markup?

Paste a page URL into Google's Rich Results Test or the Schema Markup Validator at validator.schema.org. Both list every schema type they find on the page. You can also view the page source and search for application/ld+json.

Which schema types matter most for getting found by AI?

For most service businesses, start with LocalBusiness (or a specific subtype such as LegalService or Dentist), then Service for each service you offer, and FAQPage for the questions clients ask. Together they state what the business is, what it does and where it works.

Does FAQ schema still show rich results in Google?

FAQ rich results no longer appear in Google Search: Google stopped showing them on 7 May 2026. FAQPage markup is still valid Schema.org and still useful to AI assistants reading the page, as long as the questions and answers are visible on the page too.

How long until AI tools pick up new schema?

Google usually processes schema changes within days of recrawling a page. AI assistants recrawl on their own schedules, and LovedByAI customers typically see their first AI mentions 6 to 8 weeks after their pages are optimized. Make sure AI crawlers are not blocked in robots.txt or by your firewall.

Will JSON-LD slow down my WordPress site?

JSON-LD will not noticeably slow a WordPress site. It is a block of text in a script tag, usually a few kilobytes at most, and browsers do not execute it as code.

I already have Yoast or Rank Math. Do I still need to do anything?

Most sites with Yoast or Rank Math still have gaps. Both plugins output Organization or WebSite, WebPage and Article schema automatically, but LocalBusiness details, Service and FAQPage usually need setting up page by page. Run your key pages through the Rich Results Test to see what is there.

Ready to optimize your site for AI search?

Discover how AI engines see your website and get actionable recommendations to improve your visibility.

zero manual work. zero visible changes.

Get mentioned by ChatGPT