Skip to content
ExponaBLOG
WORDPRESS DEVELOPMENT & PLUGINS · DAY 072 / 100

SEO for WordPress developers: what developers should know

Technical SEO in themes and plugins.

Expona Admin6 min read

SEO for WordPress developers: what developers should know

Most WordPress developers focus on functionality and performance, but SEO for WordPress developers: what developers should know is equally critical because technical SEO decisions made at the theme and plugin level directly impact search visibility. When your code doesn't implement proper title tags, schema markup, or URL structures, even the best content won't rank well. We'll walk through the technical foundations that every developer building WordPress themes and plugins should understand.

Proper title tags and meta descriptions via SEO plugins

Title tags and meta descriptions are your first line of communication with search engines and users in search results. As a developer, you need to understand how to make these customizable and how to implement fallbacks when plugins aren't handling them.

Most WordPress sites rely on SEO plugins like Yoast SEO, Rank Math, or All in One SEO to manage these tags. Your theme should cooperate with these plugins by not hardcoding titles and descriptions. The standard way to do this is through the wp_head hook—never output title tags manually if a plugin is already present.

If you're building a custom theme or plugin that needs to generate titles dynamically, here's how to do it properly:

php
add_filter( 'document_title_parts', function( $title_parts ) {
    if ( is_singular( 'post' ) ) {
        $title_parts['title'] = get_the_title() . ' | My Site';
    }
    return $title_parts;
} );

For meta descriptions, WordPress doesn't have a native filter by default, but SEO plugins handle this. When writing custom code, use the wp_head action to output descriptions:

php
add_action( 'wp_head', function() {
    if ( is_singular() ) {
        $description = wp_trim_words( get_the_excerpt(), 20 );
        echo '' . "\n";
    }
} );

The key principle: make your theme or plugin SEO-plugin-aware. Don't duplicate functionality. If you detect that Yoast is active, let it handle titles. If it's not active, provide sensible defaults.

Schema markup with JSON-LD

Schema markup tells search engines what your content actually represents—whether it's an article, product, event, or person. JSON-LD is the modern standard that Google recommends, and it's cleaner than embedding RDFa or microdata throughout your HTML.

Most SEO plugins generate basic schema for you, but as a developer you often need to add custom schema for specialized content types. For example, if you're building a recipe site or a local business directory, you'll need custom schema beyond what Yoast provides out of the box.

Here's how to add Article schema to a blog post programmatically:

php
add_action( 'wp_head', function() {
    if ( is_singular( 'post' ) ) {
        $post_id = get_the_ID();
        $schema = array(
            '@context'   => 'https://schema.org',
            '@type'      => 'BlogPosting',
            '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', get_post_field( 'post_author', $post_id ) ),
            ),
            'description' => wp_trim_words( get_the_excerpt( $post_id ), 20 ),
        );
        
        echo '' . "\n";
    }
} );

Always use wp_json_encode() instead of json_encode() in WordPress—it handles escaping and sanitization more reliably. And always wrap your schema in <script type="application/ld+json"> tags in the wp_head action.

Test your schema with Google's Rich Results Test tool before pushing to production. Broken schema can actually harm rankings.

WordPress permalink structure might seem like a simple setting, but it directly affects SEO and crawlability. The default index.php-based structure is a technical debt that hurts indexing.

The best permalink structure for SEO is typically /%postname%/ or /%year%/%monthnum%/%postname%/ for blogs. This creates clean, readable URLs that include keywords and hierarchy information that search engines can parse.

Your theme or plugin shouldn't hardcode URLs. Always use WordPress functions to generate them:

php
// Wrong - hardcoded
echo '<a href="/blog/my-post/">Read more</a>';

// Correct - uses WordPress functions
echo '<a href="' . esc_url( get_permalink( $post_id ) ) . '">Read more</a>';

If you're building a custom post type, register it with proper slug configuration:

php
register_post_type( 'service', array(
    'labels'  => array( 'name' => 'Services' ),
    'public'  => true,
    'rewrite' => array(
        'slug'       => 'services',
        'with_front' => false,
    ),
    'supports' => array( 'title', 'editor', 'excerpt' ),
) );

Avoid query string parameters in URLs whenever possible. If you need to pass data, use path-based rewrites instead. Query strings (those with ? and &) are slower for crawlers and less user-friendly.

Fast pages and XML sitemaps

Page speed is a confirmed Google ranking factor. As a developer, slow-loading themes and plugins are a direct SEO liability.

Focus on these critical metrics: defer non-critical JavaScript, lazy-load images, minify CSS and JavaScript, and leverage browser caching. Every plugin you include has a performance cost. Before adding a new dependency, ask yourself whether the SEO or content benefit justifies the performance hit.

Tools like Google PageSpeed Insights and GTmetrix will identify your worst offenders. Core Web Vitals—Largest Contentful Paint (LCP), First Input Delay (FID), and Cumulative Layout Shift (CLS)—are especially important for SEO.

XML sitemaps help search engines discover your content faster. WordPress has native sitemap support in WordPress 5.5+, but you can also use SEO plugins to manage them. If you're building a custom post type, ensure it's included in the sitemap:

php
add_filter( 'wp_sitemaps_post_types', function( $post_types ) {
    $post_types['service'] = array(
        'name'  => 'service',
        'object' => get_post_type_object( 'service' ),
    );
    return $post_types;
} );

Visit /wp-sitemap.xml on your site to verify it's being generated. Submit it to Google Search Console to accelerate indexing of new content.

Common mistakes

Not respecting existing SEO plugin data. If Yoast is active, don't output your own title tags. Check for active plugins before adding redundant functionality.

Hardcoding URLs throughout templates. This breaks when the site moves or URL structure changes. Always use get_permalink(), get_the_excerpt(), and similar WordPress functions.

Ignoring performance in development. A beautiful, feature-rich theme that takes 5 seconds to load will rank below a simpler, faster competitor. Measure performance early and often.

Duplicate title tags and descriptions. WordPress 5.1+ now has native support for title formatting through wp_get_document_title(). Don't override it with custom code if you're running a recent version.

Missing or incorrect schema markup. Broken JSON-LD can prevent rich snippets. Always validate schema before and after updates. Use JSON_UNESCAPED_SLASHES to keep URLs readable in the source.

Key takeaways

  • Let SEO plugins handle title tags and meta descriptions unless you have a specific reason to customize. Cooperate with them, don't compete with them.
  • Use JSON-LD for schema markup. It's the cleanest approach and Google's preferred format. Always test with the Rich Results Test tool.
  • Create clean, keyword-inclusive URL structures using proper permalink settings and WordPress functions. Avoid query strings where possible.
  • Prioritize performance at the theme and plugin level. Page speed is a ranking factor and a user experience factor.
  • Generate and maintain XML sitemaps for all custom post types. Submit them to Google Search Console to accelerate discovery.
  • Check for active SEO plugins before adding your own title, description, or schema code. Duplicate functionality creates conflicts.
ShareXLinkedInReddit

Found this useful? Support the writing.

Buy me a coffee
Written by
Expona Admin
Site administrator

Comments

Loading comments…

Leave a comment

Comments are reviewed before they appear. Be kind and stay on topic.

Related articles