How to Add Schema Markup to a WordPress Site Without a Plugin
Why Add Schema Markup to WordPress Manually? If you have ever searched for a recipe, a product, or a local business on Google and noticed rich results with star ratings, FAQ dropdowns, or business details right on the search page, you have seen schema markup in action. Schema markup is structured data that helps search engines understand your content more precisely. While there are plenty of WordPress plugins that handle this for you, there are strong reasons to add schema markup to WordPress without a plugin: Performance: Every plugin you install adds weight to your site. Manually adding JSON-LD keeps your site lean and fast. Control: You decide exactly what structured data appears on each page, with no bloated or unnecessary output. Reliability: You are not dependent on plugin updates, compatibility issues, or abandoned projects. Learning: Understanding schema at the code level gives you a significant SEO advantage over competitors who rely solely on automated tools. In this guide, we will walk through exactly how to add schema markup to a WordPress site manually using JSON-LD, covering the three most common schema types for business websites: LocalBusiness, Article, and FAQ. What Is JSON-LD and Why Should You Use It? JSON-LD stands for JavaScript Object Notation for Linked Data. It is the format that Google officially recommends for adding structured data to web pages. Unlike older methods like Microdata or RDFa, JSON-LD is placed inside a <script> tag and does not interfere with your visible HTML content. Here is why JSON-LD is the best choice when you want to add schema markup to WordPress manually: Format Placement Google Recommended Ease of Use JSON-LD Inside a script tag in head or body Yes Easy Microdata Inline within HTML elements Supported but not preferred Moderate RDFa Inline within HTML elements Supported but not preferred Complex The bottom line: JSON-LD is clean, separate from your markup, and the easiest to maintain. Before You Start: What You Need Before adding schema markup manually, make sure you have the following: Access to your WordPress theme files (via Appearance > Theme File Editor or FTP/SFTP). A child theme (strongly recommended so your changes survive theme updates). Basic comfort with editing PHP files or using the WordPress custom HTML block. Google’s Rich Results Test tool bookmarked at search.google.com/test/rich-results for validation. Now let us get into the actual implementation. Method 1: Add Schema Markup Directly in WordPress Posts and Pages The simplest way to add schema markup to WordPress without a plugin is to paste JSON-LD code directly into individual posts or pages using the Custom HTML block in the WordPress block editor (Gutenberg). Step 1: Prepare Your JSON-LD Code Write your structured data following the Schema.org vocabulary. We will cover specific examples for each schema type below. Step 2: Open Your Post or Page in WordPress Navigate to the post or page where you want to add the schema. Switch to the block editor if you are not already using it. Step 3: Add a Custom HTML Block Click the + button to add a new block. Search for “Custom HTML” and select it. Paste your JSON-LD script into the block. The block will not display anything visible on the front end, but the script will be present in the page source code where search engines can read it. Step 4: Validate Your Markup After publishing or updating the page, copy the URL and paste it into Google’s Rich Results Test. Fix any errors or warnings before moving on. Method 2: Add Schema Markup Site-Wide via functions.php If you want to add schema markup to WordPress across your entire site (for example, adding Article schema to every blog post automatically), you can inject JSON-LD through your theme’s functions.php file. Step 1: Open Your Child Theme’s functions.php Go to Appearance > Theme File Editor and select your child theme’s functions.php file. Step 2: Add a PHP Function to Output JSON-LD Here is an example that automatically adds Article schema to every single blog post: function expressjs_add_article_schema() { if ( is_single() ) { global $post; $schema = array( ‘@context’ => ‘https://schema.org’, ‘@type’ => ‘Article’, ‘headline’ => get_the_title( $post->ID ), ‘datePublished’ => get_the_date( ‘c’, $post->ID ), ‘dateModified’ => get_the_modified_date( ‘c’, $post->ID ), ‘author’ => array( ‘@type’ => ‘Person’, ‘name’ => get_the_author_meta( ‘display_name’, $post->post_author ), ), ‘publisher’ => array( ‘@type’ => ‘Organization’, ‘name’ => get_bloginfo( ‘name’ ), ‘logo’ => array( ‘@type’ => ‘ImageObject’, ‘url’ => ‘https://yoursite.com/logo.png’, ), ), ‘description’ => get_the_excerpt( $post->ID ), ‘mainEntityOfPage’ => get_permalink( $post->ID ), ); if ( has_post_thumbnail( $post->ID ) ) { $schema[‘image’] = get_the_post_thumbnail_url( $post->ID, ‘full’ ); } echo ‘<script type=”application/ld+json”>’ . wp_json_encode( $schema, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT ) . ‘</script>’; } } add_action( ‘wp_head’, ‘expressjs_add_article_schema’ ); Important: Replace https://yoursite.com/logo.png with the actual URL of your organization’s logo. Step 3: Save and Test Save the file, then visit any blog post on your site. View the page source (Ctrl+U or Cmd+U) and search for application/ld+json to confirm the schema is present. Then validate with Google’s Rich Results Test. Schema Type 1: LocalBusiness Schema (For Business Websites) If you run a local business, the LocalBusiness schema type is essential. It tells Google your business name, address, phone number, opening hours, and more. This can lead to enhanced results in local search and Google Maps. JSON-LD Example for LocalBusiness Paste this into a Custom HTML block on your homepage or contact page: <script type=”application/ld+json”> { “@context”: “https://schema.org”, “@type”: “LocalBusiness”, “name”: “Your Business Name”, “description”: “A brief description of what your business does.”, “url”: “https://yourwebsite.com”, “telephone”: “+1-555-123-4567”, “email”: “[email protected]”, “address”: { “@type”: “PostalAddress”, “streetAddress”: “123 Main Street”, “addressLocality”: “Your City”, “addressRegion”: “Your State”, “postalCode”: “12345”, “addressCountry”: “US” }, “geo”: { “@type”: “GeoCoordinates”, “latitude”: “40.7128”, “longitude”: “-74.0060” }, “openingHoursSpecification”: [ { “@type”: “OpeningHoursSpecification”, “dayOfWeek”: [“Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”], “opens”: “09:00”, “closes”: “17:00” } ], “image”: “https://yourwebsite.com/images/storefront.jpg”, “priceRange”: “$$” } </script> Fields to Customize Field What to Enter name Your official business name telephone Your primary phone number in international format address Your complete physical address geo Latitude and longitude (use
How to Add Schema Markup to a WordPress Site Without a Plugin Read More »









