Table of Contents
Schema markup (structured data) helps Google understand your content and display rich snippets — star ratings, FAQs, breadcrumbs. While plugins like Rank Math add it automatically, you can implement JSON-LD manually for full control.
What Is Schema Markup?
Schema.org vocabulary describes your content in a machine-readable format. Google uses it for rich results: review stars, FAQ dropdowns, recipe cards, event dates. Implemented as JSON-LD (preferred by Google) in a <script type="application/ld+json"> tag.
Method 1: functions.php (Recommended)
Add JSON-LD via your child theme’s functions.php. This injects schema on every post:
add_action('wp_head', function() {
if (is_single()) {
$schema = array(
'@context'=>'https://schema.org',
'@type'=>'BlogPosting',
'headline'=>get_the_title(),
'author'=>get_the_author(),
'datePublished'=>get_the_date('c')
);
echo '<script type="application/ld+json">'.json_encode($schema).'</script>';
}
});
Method 2: Custom Fields
For per-post control, create a custom field “schema_json” and output it in your single.php template. This lets you add FAQ, Recipe, or Product schema individually.
Common Schema Types
- BlogPosting / Article: blog posts, news
- FAQPage: FAQ sections (eligible for FAQ rich results)
- BreadcrumbList: navigation path
- WebSite: site-level info with search box
- Organization: business details, logo, social profiles
FAQ Schema Example
{
"@context":"https://schema.org",
"@type":"FAQPage",
"mainEntity":[{
"@type":"Question",
"name":"What is schema markup?",
"acceptedAnswer":{"@type":"Answer","text":"..."}
}]
}
Validate Your Schema
Use Google’s Rich Results Test (search.google.com/test/rich-results) and Schema Markup Validator (validator.schema.org). Paste your URL or code to confirm it’s valid and eligible for rich results.
Frequently Asked Questions
Is manual schema better than a plugin? Not necessarily. Plugins (Rank Math) are easier and update automatically. Manual gives control for custom types but requires maintenance. Use plugins unless you need something specific.
Will schema guarantee rich snippets? No — Google decides when to show rich results. Valid schema increases eligibility but isn’t a guarantee. Focus on quality content too.
Can I break my site with functions.php? Yes — a PHP error there breaks your site. Always use a child theme and test on staging. Syntax errors are the main risk; validate PHP before saving.
Conclusion
Manual JSON-LD schema is powerful for custom needs. Add BlogPosting via functions.php, use custom fields for FAQ/Recipe schema, and validate with Google’s tools. For most sites, a plugin like Rank Math is simpler — but knowing the manual method gives you ultimate control.


