Introduction
If you want better SEO, you need structured data.
For blog posts, BlogPosting schema helps Google understand your content. It can also show rich results.
Many people use plugins for this. But plugins can slow site or create extra load.
If you are using custom theme, better to add it manually.
This guide shows simple way to add schema for all posts without plugin.
What You Need
You want:
- Schema on every post
- No plugin
- No manual edit per post
Best way is using JSON-LD.
Why JSON-LD
Google prefers JSON-LD format.
It is:
- Clean
- Easy to manage
- Works in
<head>
No need to change HTML layout.
Where to Add Code
You can add code in:
functions.php
OR- separate custom PHP file
This will apply to all posts automatically.
Simple Working Code
Add this code:
add_action('wp_head', function() { if (!is_single()) return; $schema = array(
"@context" => "https://schema.org",
"@type" => "BlogPosting",
"headline" => get_the_title(),
"description" => get_the_excerpt(),
"author" => array(
"@type" => "Person",
"name" => get_the_author()
),
"datePublished" => get_the_date('c'),
"dateModified" => get_the_modified_date('c'),
"mainEntityOfPage" => get_permalink(),
"publisher" => array(
"@type" => "Organization",
"name" => get_bloginfo('name')
)
); echo '<script type="application/ld+json">' . json_encode($schema) . '</script>';});What This Code Does
This code:
- Runs on post pages only
- Gets data from WordPress
- Creates schema automatically
- Adds it inside
<head>
So every post gets structured data.
You Can Also Add More Fields
If needed, you can add:
- Featured image
- Category
- Tags
- Custom fields (ACF)
Example:
"image" => get_the_post_thumbnail_url(),
Small Example
One site used plugin for schema.
After removing plugin and adding this code:
- Site speed improved
- Schema still worked
- No manual work needed
Common Mistakes
- Adding schema in wrong place
- Not checking if page is post
- Using wrong format (not JSON-LD)
- Missing required fields
How to Test
After adding code:
- Open any post
- View page source
- Search for
application/ld+json
Then test in:
- Google Rich Results Test
Why This Is Good for SEO
Schema helps search engines understand content better.
Benefits:
- Better indexing
- Rich results
- More visibility
FAQs
Do I need plugin for schema?
No, you can add manually.
Which format to use?
JSON-LD
Will this work for all posts?
Yes, if added correctly.
Can I use ACF data?
Yes, you can add custom fields.
Where to place code?
functions.php or custom file
Final
This is simple and clean way.
No plugin needed.
No extra work per post.
Once added, all posts get schema automatically

