How to Add Custom schema Markup in WordPress without plugins

If you want your WordPress website to stand out in Google search results with star ratings, FAQs, events, or business info, adding schema markup (also called structured data) can help.
In this post, weโll explain step-by-step how to add custom schema markup to your WordPress site without using any plugins.
What is Schema Markup?
Schema markup is a special code (usually in JSON-LD format) that helps search engines understand your content better.
For example, if you have a recipe post, you can use recipe schema to show ingredients, cooking time, and ratings in Google results. This can improve your SEO and click-through rate.
Step-by-Step: How to Add Custom Schema Markup in WordPress Without Plugins
Use the Below PHP code directly in the Appearance > Theme file editor >Function.php file.
// Custom Schema Markup Field function output_custom_schema_in_head() { if (is_single() || is_page()) { global $post; $schema = get_post_meta($post->ID, 'custom_schema', true); if (!empty($schema)) { echo '<script type="application/ld+json">' . $schema . '</script>'; } } } add_action('wp_head', 'output_custom_schema_in_head');
After that you need to open the Post editor and enable the Custom field option from Preference as shown in this video.
Now you need to add custom_schema in the name field and you need to paste your schema code and add it to the blog post. Follow the video to learn more.
Final Tips
- Always use valid JSON-LD format.
- Update schema when you change page content.
- Consider using a child theme to avoid losing changes during theme updates.
- Use schema types that are relevant to your content
Conclusion
Adding custom schema markup in WordPress without plugins may seem technical, but itโs totally doable. It gives you more control, improves your SEO, and helps search engines understand your site better.
Just follow the steps above carefully, and test your code before publishing.
Have any questions or want help with your schema code? Let me know in the comments!