Skip to content

WordPress structured data: schema markup that earns rich results

WordPress structured data done properly — which schema types still earn rich results, JSON-LD from a plugin or a wp_head hook, how to kill duplicate graphs, and how to validate what the page actually ships.

Use JSON-LD, emit exactly one graph per page, and let your SEO plugin carry the types it already knows: Organization or LocalBusiness sitewide, Article on posts, Product on WooCommerce, BreadcrumbList everywhere. Hand-roll a JSON-LD block on a wp_head hook only for the types no plugin covers. Then validate with Google’s Rich Results Test and fix what it flags.

On a small-business WordPress site the problem is almost never missing structured data. It is two plugins and a theme each emitting their own description of the same business, one required property left empty, or a full-page cache still serving markup from before the fix. This page covers which types are worth emitting in 2026, how to ship them, and how to prove what the page really sends.

What you’ll accomplish

  • Exactly one JSON-LD graph per page, with the theme’s duplicate copy switched off rather than left to compete with the plugin’s.
  • A correct site-level identity — LocalBusiness with address and hours if there is a physical location, Organization if there is not — configured once and reused on every page.
  • A hand-rolled JSON-LD block for the one type your plugin does not cover, in a small plugin that survives theme and plugin updates.
  • A curl and WP-CLI check you can rerun after any deploy to prove the markup still ships, and still ships once.
  • A realistic sense of which schema types still produce a visible result in Google and which are now bookkeeping.

Prerequisites

  • WordPress 6.0 or newer on PHP 8.1 or newer. Nothing here needs a specific version, but the plugin menus below moved in the last few major releases of each plugin.
  • Exactly one SEO plugin active: Yoast SEO, Rank Math, All in One SEO, or Schema Pro. Two of them running together is the single most common source of duplicate graphs.
  • Write access to wp-content/mu-plugins/ or a child theme. Never edit a parent theme’s functions.php — the next theme update deletes your work.
  • Shell access with curl, plus WP-CLI if you want the server-side check.
  • The ability to purge whatever page cache sits in front of PHP: LiteSpeed Cache, WP Rocket, Varnish, Cloudflare, or all of them stacked.
  • A verified Search Console property, so the enhancement reports have somewhere to appear. If you do not have one, start with Search Console setup for WordPress.
  • A public, indexable site. Structured data on a staging copy does nothing.

How it works

Schema.org vocabulary can be expressed three ways: JSON-LD, Microdata attributes woven into the HTML, and RDFa. Google reads all three, documents JSON-LD as its preference, and JSON-LD is the only one you can change without touching templates. Everything below assumes JSON-LD.

WordPress itself has no structured data layer. There is no core API for schema, no registry, and no deduplication. Every source that wants to describe the page prints its own script block during wp_head, and whatever comes out lands in the rendered HTML in hook order.

Data flow showing an SEO plugin, a theme and custom code all printing JSON-LD into wp_head, the rendered HTML passing through a page cache, and Googlebot and the Rich Results Test reading the result

Modern SEO plugins do not emit one node per entity. They emit a single @graph array holding several nodes — the organization, the website, the web page, the breadcrumb trail, the article — each with an @id so the nodes can reference one another. That interconnection is exactly why a second emitter causes trouble. When a theme adds its own standalone Organization block, Google sees two unlinked descriptions of the same business with no shared @id, and has to guess which one is authoritative.

Eligibility is the other half of the mechanism, and it is where most guidance is out of date. Valid markup makes a page eligible for a rich result. It does not produce one. Google decides per query, and it has been narrowing the field: HowTo rich results were retired outright, and FAQ rich results were restricted to a small set of government and health sites, so ordinary business sites no longer see them regardless of how correct the markup is. Product, breadcrumb, and business-panel data still earn visible treatment. Article markup rarely produces a distinct visual result but is still the correct way to declare author and dates.

Finally, JSON-LD is part of the HTML document, so it is cached along with it. If a full-page cache or CDN is in front of the site, editing your schema changes nothing anyone can see until that cache is purged. Several “the plugin isn’t working” reports resolve at exactly that step.

Step-by-step

  1. Inventory what the site already emits before changing anything. Count the blocks on a representative page of each type — home, a post, a product:

    for u in / about/ blog/hello-world/ ; do
      printf '%-24s %s\n' "$u" "$(curl -s "https://example.com/$u" | grep -c 'application/ld+json')"
    done

    Expected output on a healthy site is one block per URL:

    /                        1
    about/                   1
    blog/hello-world/        1

    A 2 or 3 anywhere is the duplicate-graph problem, and fixing it comes before adding anything new.

  2. Decide which types belong on which pages. Do this from the page’s purpose, not from the plugin’s feature list. Emitting a type you cannot keep accurate is worse than emitting nothing.

    Decision table mapping page type to schema type to delivery method, with a note that FAQPage and HowTo rarely earn a rich result

  3. Fill in the site-level identity in your SEO plugin. This is the one piece every site needs and the one most often left at its defaults. In Yoast SEO it is under SEO > Settings > Site representation: choose Organization or Person, set the name, and upload a logo. In Rank Math it is Titles and Meta > Local SEO, where the same fields sit alongside address and opening hours. Set a real logo — Google’s guidance asks for at least 112 by 112 pixels, and a wider image serves other surfaces better.

  4. Switch off the second emitter. Most commercial themes have a schema toggle buried in their options panel; use it if it exists. If the theme offers no switch, the reverse approach works: keep the theme’s block and strip the duplicate node out of the plugin’s graph. For Yoast SEO, filter the graph before it is printed. Put this in wp-content/mu-plugins/schema-dedupe.php:

    <?php
    /**
     * Plugin Name: Schema dedupe
     * Description: Removes the LocalBusiness node from Yoast's graph
     *              because the theme already prints its own.
     */
    
    add_filter( 'wpseo_schema_graph', 'sh_drop_duplicate_localbusiness', 11, 2 );
    
    function sh_drop_duplicate_localbusiness( $graph, $context ) {
        foreach ( $graph as $index => $piece ) {
            $types = isset( $piece['@type'] ) ? (array) $piece['@type'] : array();
            if ( in_array( 'LocalBusiness', $types, true ) ) {
                unset( $graph[ $index ] );
            }
        }
    
        return array_values( $graph );
    }

    Rerun the count from step 1. The success signal is every URL back to 1.

  5. Hand-roll JSON-LD only for what no plugin covers. A single-location business whose SEO plugin has no free local module is the usual case. Create wp-content/mu-plugins/localbusiness-schema.php:

    <?php
    /**
     * Plugin Name: LocalBusiness schema
     * Description: Emits one LocalBusiness node on the front page.
     */
    
    add_action( 'wp_head', 'sh_localbusiness_jsonld', 20 );
    
    function sh_localbusiness_jsonld() {
        if ( ! is_front_page() ) {
            return;
        }
    
        $schema = array(
            '@context'  => 'https://schema.org',
            '@type'     => 'LocalBusiness',
            '@id'       => home_url( '/#localbusiness' ),
            'name'      => get_bloginfo( 'name' ),
            'url'       => home_url( '/' ),
            'telephone' => '+1-514-555-0142',
            'image'     => 'https://example.com/wp-content/uploads/storefront.jpg',
            'address'   => array(
                '@type'           => 'PostalAddress',
                'streetAddress'   => '1290 rue Sainte-Catherine Ouest',
                'addressLocality' => 'Montreal',
                'addressRegion'   => 'QC',
                'postalCode'      => 'H3G 1P6',
                'addressCountry'  => 'CA',
            ),
            'openingHoursSpecification' => array(
                array(
                    '@type'     => 'OpeningHoursSpecification',
                    'dayOfWeek' => array( 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday' ),
                    'opens'     => '07:00',
                    'closes'    => '18:00',
                ),
            ),
        );
    
        echo '<script type="application/ld+json">'
            . wp_json_encode( $schema, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE )
            . '</script>' . "\n";
    }

    Three details matter here. Priority 20 runs after most plugin output, which keeps the block from landing before the character set declaration. wp_json_encode is the WordPress wrapper and is the correct choice over raw json_encode — it handles invalid UTF-8 the way WordPress expects. And JSON_UNESCAPED_UNICODE keeps accented characters readable instead of turning Sainte-Catherine into escape sequences, which matters when a human has to read the output during debugging.

    The success signal is the block appearing in the page source. Reload the home page, view source, and search for localbusiness.

  6. Purge every cache in front of PHP. In order: the object cache, the page cache plugin, then the CDN.

    wp cache flush

    Then purge the page cache from its own admin screen — LiteSpeed Cache, WP Rocket, and W3 Total Cache each have a one-click purge — and purge the CDN from its dashboard if one is in front. Confirm with a cache-busting request:

    curl -s "https://example.com/?nocache=$(date +%s)" | grep -c 'application/ld+json'

    Expected output:

    1
  7. Ask Google to look again. In Search Console, run URL Inspection on the changed page and use Request Indexing. This is a nudge, not an instruction; recrawl typically takes days, and the enhancement reports lag behind that.

Validate it works

Validate in three places, because each answers a different question.

Confirm the page ships the markup at all. Extract the block itself, not just the count:

curl -s https://example.com/ \
  | sed -n 's/.*<script type="application\/ld+json"[^>]*>\(.*\)<\/script>.*/\1/p' \
  | python3 -m json.tool | head -20

Expected output is readable JSON beginning with the context and type:

{
    "@context": "https://schema.org",
    "@type": "LocalBusiness",
    "@id": "https://example.com/#localbusiness",
    "name": "Boulangerie Rousseau",

If python3 -m json.tool reports a decode error, the JSON is malformed and Google is discarding the whole block. Go to the last troubleshooting entry below.

Confirm the markup is server-side, not something a cache is hiding. From WP-CLI, render the head and count:

wp eval 'ob_start(); do_action( "wp_head" ); $h = ob_get_clean(); echo substr_count( $h, "application/ld+json" ), " block(s)\n";'

Expected output:

1 block(s)

A 1 here with a 0 from curl means the cache is serving an older copy. A 2 here means you still have two emitters.

Confirm Google can use it. Run the live URL through the Rich Results Test at https://search.google.com/test/rich-results. It reports only the features Google supports, so a valid type it does not use shows as “no items detected” rather than an error. For full vocabulary conformance, run the same URL through the Schema.org validator, which checks the markup against the specification without Google’s eligibility filter. Use both: the first tells you what Google will act on, the second tells you whether your JSON is correct.

Then wait. In Search Console, the enhancement reports under the Experience and Enhancements sections populate only after Googlebot recrawls the affected URLs, which is normally days and can be weeks on a small site. An empty report the day after a change is expected, not a failure.

Troubleshooting

Two graphs, one from the theme and one from the plugin. The count from step 1 returns 2 or higher, and the Rich Results Test lists the same business twice. Identify the sources by looking at the raw HTML — plugin output is usually a single long line with an @graph array, while theme output tends to be pretty-printed. Disable one. Never solve this by disabling both and starting over; the plugin’s version is generally the more complete of the two.

Required properties missing. The Rich Results Test reports errors rather than warnings for these. Product needs name plus at least one of offers, review, or aggregateRating, and an offers node needs price and priceCurrency. Article needs headline and image, and the usual cause of a missing image is a post published without a featured image. LocalBusiness needs address with a real PostalAddress, not a single free-text string. Warnings are optional properties and can be ignored; errors mean the item is not eligible at all.

Valid markup, no rich result. This is the most common outcome and usually not a bug. Eligibility is not entitlement — Google chooses per query. Before assuming a technical fault, check three things: the page is actually indexed (URL Inspection says so), the marked-up content is visible to a human on the page, and the type still has a rich result at all. Marking up FAQ or HowTo content and waiting for a snippet that Google no longer shows is wasted effort.

Schema changes are invisible after saving. A full-page cache or CDN is serving the old HTML. Confirm the split with the WP-CLI check above: server-side output correct, curl output stale. Purge in order — object cache, page cache, CDN — and retest with a cache-busting query string. On LiteSpeed and Cloudflare together, purging only one of the two is the usual mistake.

Malformed JSON that Google discards silently. Google does not report a broken block; it ignores it, so the Rich Results Test simply says nothing was detected. The usual causes are a stray echo or a BOM printed before the block, a plugin that concatenates strings by hand instead of encoding an array, and unescaped quotes in a business name or address. Encoding a PHP array with wp_json_encode prevents all three. If a plugin is the source, test by deactivating it and rerunning the extraction.

Yoast’s graph filter does not fire. wpseo_schema_graph runs only when Yoast is actually rendering schema on that request. If the page is served from a cache, or Yoast’s schema output has been disabled elsewhere, the filter never runs and the duplicate stays. Check the plugin is active and its schema output enabled before debugging the snippet itself; common Yoast SEO problems covers the settings that silence its output entirely.

When this is the wrong approach

Structured data is not a ranking factor. It changes how a result is presented when Google chooses to use it; it does not move a page up the results. If the site is not ranking, schema markup is not the lever, and time spent here is time not spent on the content and links that are.

Marking up content that is not visible on the page violates Google’s structured data policies and can earn a manual action. If the address in your LocalBusiness node is not printed somewhere a visitor can read it, fix the page, not the markup.

Building FAQPage or HowTo markup to chase a snippet is chasing something that no longer exists for a typical business site. Emit those types if they describe your content accurately and you will maintain them; do not build them expecting a visual payoff.

If the site has a broader indexing problem — pages not indexed, canonicals fighting each other, a noindex left on from staging — structured data is downstream of all of it. Fix indexing first.

And once the site outgrows a handful of hand-maintained pages, hand-rolled JSON-LD stops being the right tool. Multiple locations, a real product catalogue, or a job board all need schema generated from the data that already exists in the database, not from literals in a PHP file that drift out of date the first time someone changes an opening hour in the CMS and not in the code. For the authoritative reference on what each type requires, work from Google’s structured data documentation rather than a plugin vendor’s summary.

Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.