Subtle diagonal pinstripe pattern in light grey and cream, giving an impression of printed editorial paper

Add Schema.org JSON-LD to WordPress Posts

Schema.org JSON-LD gives WordPress posts a machine-readable summary that search engines can interpret beyond the visible words on a page. Instead of relying on layout heuristics, the markup identifies the article, author, publisher, dates, image and canonical page as distinct entities. That semantic context can support eligible rich results and make technical audits more reliable.

Adding it does not guarantee a rich result because Google also judges content quality, eligibility and page experience. The safest approach is to generate one accurate schema graph from WordPress data, test it after publication and keep it aligned with what visitors can see.

What Schema.org JSON-LD Does

Schema.org is a shared vocabulary for describing entities on the internet. A blog post can be represented as an Article, BlogPosting or NewsArticle, while its writer, publication and featured image receive their own structured definitions. Search engines can then connect those entities instead of guessing their meaning from CSS classes and visual placement.

JSON-LD is the preferred way to express this information because it remains separate from the page design. A script with the type application/ld+json contains properties such as headline, datePublished, author and publisher. The vocabulary supplies the meaning, while JSON-LD provides a compact syntax that can be generated directly by PHP or a WordPress plugin.

Choose an Implementation Method

For most WordPress sites, an SEO plugin such as Yoast or Rank Math is the quickest route. These plugins can generate article schema from post fields and combine it with organisation, breadcrumb and social metadata. Their built-in settings are useful for standard blogs, although premium features and configuration differences can affect the final output.

For a bespoke implementation, place PHP in a child theme or a small custom plugin. When the metadata work forms part of a larger WordPress rebuild, the project delivery guide can help separate content modelling, template changes and launch checks into manageable stages. A dedicated plugin is usually easier to version and deploy when several sites use the same setup.

Choose one source of schema data. If an SEO plugin already emits BlogPosting markup, adding an identical custom block can create conflicting or duplicated entities. Review the page source first, then either configure the plugin or replace its article output with the custom implementation.

Create a Post Schema Template

A reliable template pulls each value from the current post and excludes unavailable properties. The following example belongs inside the PHP context of a child theme or plugin:

add_action( 'wp_head', 'au_post_json_ld' );

function au_post_json_ld() {
    if ( ! is_singular( 'post' ) ) {
        return;
    }

    $post = get_queried_object();
    $description = $post->post_excerpt
        ? wp_strip_all_tags( $post->post_excerpt )
        : wp_trim_words( wp_strip_all_tags( $post->post_content ), 55 );

    $publisher = array(
        '@type' => 'Organization',
        'name'  => get_bloginfo( 'name' ),
        'url'   => home_url( '/' ),
    );

    $logo_id = get_theme_mod( 'custom_logo' );
    $logo_url = $logo_id
        ? wp_get_attachment_image_url( $logo_id, 'full' )
        : '';

    if ( $logo_url ) {
        $publisher['logo'] = array(
            '@type' => 'ImageObject',
            'url'   => $logo_url,
        );
    }

    $schema = array(
        '@context'          => 'https://schema.org',
        '@type'             => 'BlogPosting',
        '@id'               => get_permalink( $post ) . '#post',
        'headline'          => wp_strip_all_tags( get_the_title( $post ) ),
        'description'       => $description,
        'image'             => get_the_post_thumbnail_url( $post, 'full' ),
        'datePublished'     => get_the_date( 'c', $post ),
        'dateModified'      => get_the_modified_date( 'c', $post ),
        'mainEntityOfPage' => array(
            '@type' => 'WebPage',
            '@id'   => get_permalink( $post ),
        ),
        'author'            => array(
            '@type' => 'Person',
            'name'  => get_the_author_meta(
                'display_name',
                (int) $post->post_author
            ),
        ),
        'publisher'         => $publisher,
        'inLanguage'        => get_bloginfo( 'language' ),
    );

    $schema = array_filter(
        $schema,
        static function ( $value ) {
            return ! empty( $value );
        }
    );

    echo '<script type="application/ld+json">' .
        wp_json_encode(
            $schema,
            JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE |
            JSON_HEX_TAG | JSON_HEX_AMP |
            JSON_HEX_APOS | JSON_HEX_QUOT
        ) .
        '</script>';
}

The generated graph should match the information displayed on the post. The headline comes from the title, the description from the excerpt or content, and the dates from WordPress. Absolute image and canonical URLs are preferable to relative paths, while wp_json_encode() safely escapes values for inclusion in a script element.

Use BlogPosting for standard editorial content and NewsArticle only when the post satisfies news publishing requirements. Change Organization to Person for a publication operated by an individual, and add a publisher logo that meets the applicable search-engine size and accessibility requirements.

Install Markup Without Breaking WordPress

Place custom code in an active child theme or a versioned plugin rather than directly in a parent theme. Parent theme updates can otherwise overwrite the implementation. A child theme suits a single site, while a small plugin is more portable for agencies, multisite networks and sites managed by different administrators.

The wp_head hook places the generated block in the document head without changing the post editor. The condition is_singular( 'post' ) prevents the output from appearing on archives, search results and unrelated pages. Caching plugins may retain older markup, so purge the page cache and inspect the live source after deployment.

Avoid pasting the same JSON-LD into individual posts with a Custom HTML block. That approach creates repetition, misses metadata changes and makes large editorial libraries difficult to maintain. Also check that security plugins, optimisation plugins and the theme do not strip script elements or delay the output until after crawlers have finished reading the page.

Adapt Structured Data for Australia

For an Australian publisher, set the WordPress language to en-AU and use the actual business location in the organisation data. addressCountry should be AU, state names should use Australian abbreviations such as NSW, VIC, QLD or WA, and a public telephone number should use international +61 format without the domestic trunk prefix. These values should reflect the .com.au website rather than an unrelated overseas branch.

Service businesses serving Sydney, Melbourne, Brisbane or Perth can describe their coverage with areaServed. A list of City objects is suitable when the publisher genuinely operates in those areas. If there is no public street address, do not invent a PostalAddress merely to complete the markup; accurate service-region information is more useful than false precision.

For a WooCommerce site on an Australian domain, product markup should use priceCurrency with the value AUD. Prices shown in buying guides should also match the visible product page, including whether GST is included and whether delivery is available. The Australian Competition and Consumer Commission scrutinises misleading price claims, so structured data must not advertise a saving, stock status or discount that customers cannot verify. When a post describes an event, use the correct IANA timezone. Sydney and Perth observe daylight saving, Adelaide has a different offset, and Brisbane remains on Australian Eastern Standard Time throughout the year.

Validate Every Published Post

Run the Google Rich Results Test on a representative published post, then use the Schema Markup Validator to catch broader vocabulary and syntax issues. Google’s tool focuses on properties connected to eligible search features, while the Schema.org validator checks the graph against the complete vocabulary. In WordPress, use Search Console’s URL Inspection tool to confirm that Google can fetch and render the page.

Common failures include missing authors, malformed dates, relative URLs, an image that differs from the visible featured image and publisher details that do not match the site. Duplicate blocks can make two dates or names appear authoritative, while an empty image property may fail validation. Check at least one recent post, an older post, a post without a featured image and a page served from the cache.

Test the live HTML rather than only the WordPress preview because plugins and optimisation settings can alter the final output. One valid JSON-LD script should be present for the article, and its @id values should point back to the same canonical post. After changing the template, redeploy it, clear every cache layer and request another crawl through Search Console.

Keep Structured Data Accurate

Treat structured data as generated content with maintenance rules. Store custom implementations in version control, document which plugin owns each schema type and test template changes against a staging site. Periodically review author names, publisher details, image dimensions, canonical URLs and the accuracy of modified dates in Search Console.

Approach Best fit Control Ongoing upkeep Main risk
SEO plugin settings Standard editorial sites Medium Monitor plugin configuration Duplicate or conflicting output
Child theme PHP Bespoke single-site design High Maintain child theme releases Changes lost without version control
Custom plugin Multisite or agency deployments High Version and document releases Poor deployment ownership
Hard-coded post block Temporary prototypes Low Edit every published post Repetition and metadata drift

Review performance through search visibility, valid item counts and eligible-result reporting rather than assuming that structured data directly increases traffic. Changes to schema should accompany meaningful content updates, not routine plugin maintenance. A tested, automatically generated schema layer gives WordPress posts a consistent semantic foundation while preserving a familiar publishing workflow for Australian content teams.