SponsoredHosinger Special Offer

WP WordPress Theme Development

Build classic and block WordPress themes from scratch: the template hierarchy, The Loop, the_title() and the_content(), template parts, menus, the Customizer, child themes and theme.json.

Theme Features with add_theme_support()

WordPress Theme Development Lesson 11 of 30 ~4 min read

Overview

add_theme_support() tells WordPress which optional features your theme is ready to handle — such as letting WordPress manage the page title, enabling featured images, or letting the site owner upload a logo.

Features are opt-in so that old themes keep working. Each call is a promise: "my templates will display this properly."

The complete GDC Starter setup

<?php
function gdc_starter_setup() {
    // WordPress prints a correct <title> inside wp_head().
    add_theme_support( 'title-tag' );

    // Adds the Featured Image box to posts and pages.
    add_theme_support( 'post-thumbnails' );

    // RSS feed links in <head>.
    add_theme_support( 'automatic-feed-links' );

    // Modern, valid markup for these core features.
    add_theme_support(
        'html5',
        array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script', 'navigation-widgets' )
    );

    // A logo the site owner uploads in Appearance → Customize.
    add_theme_support(
        'custom-logo',
        array(
            'height'      => 80,
            'width'       => 240,
            'flex-height' => true,
            'flex-width'  => true,
        )
    );

    // Block editor features.
    add_theme_support( 'wp-block-styles' );
    add_theme_support( 'align-wide' );
    add_theme_support( 'responsive-embeds' );
    add_theme_support( 'editor-styles' );
    add_editor_style( 'assets/css/editor.css' );
}
add_action( 'after_setup_theme', 'gdc_starter_setup' );

What each feature gives you

FeatureWhat changesYour job in templates
title-tagWordPress outputs the <title>Remove any hard-coded <title>.
post-thumbnailsFeatured Image panel appearsPrint it with the_post_thumbnail() (lesson 19).
custom-logoLogo upload in the CustomizerPrint it with the_custom_logo().
html5Search forms, comments and galleries use semantic HTML5Nothing — it is markup only.
align-wideWide and full-width alignment options in the editorStyle .alignwide and .alignfull.
responsive-embedsVideos keep their aspect ratioNothing.
editor-stylesThe editor loads your stylesheetWrite editor.css so the editor looks like the front end.

Printing the custom logo

<div class="site-branding">
    <?php if ( has_custom_logo() ) : ?>
        <?php the_custom_logo(); ?>
    <?php else : ?>
        <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
    <?php endif; ?>
</div>

the_custom_logo() outputs a linked image with the correct alt text and srcset. The fallback to the site name means the header never ends up empty.

Making the editor match the front end

With editor-styles on, assets/css/editor.css is loaded into the block editor and automatically scoped so it only styles the content area:

/* assets/css/editor.css */
body {
    font-family: "Inter", system-ui, sans-serif;
    font-size: 18px;
    line-height: 1.7;
    color: #1e293b;
}

h1, h2, h3 {
    font-family: "Syne", system-ui, sans-serif;
    line-height: 1.2;
}

a {
    color: #6c63ff;
}
Tip: When the editor looks like the published page, clients make far fewer "it looked different when I wrote it" support requests.

Checking for a feature

current_theme_supports( 'post-thumbnails' ) returns whether a feature is on. Plugins use it to adapt to your theme — another reason to declare features honestly.

Practice

  • Add every feature above, then remove any <title> from header.php and confirm the browser tab still shows the right title.
  • Upload a logo in Appearance → Customize → Site Identity and confirm it replaces the site name.
  • Write editor.css and compare a post in the editor and on the front end.
Create a free account to save which lessons you've finished. Save my progress