Theme Support Generator

Generate the after_setup_theme block: the add_theme_support() calls a theme needs, the HTML5 list, the custom logo arguments and any extra image sizes.

Live output

Enable JavaScript to customise; default output below.

More options Show

From the core list: aside, gallery, link, image, quote, status, video, audio, chat.

Live preview theme-support.php
<?php
/**
 * Theme setup.
 */

/**
 * Declares what the theme supports.
 *
 * Everything here runs on after_setup_theme, which is the first hook where the
 * theme exists and the last one before WordPress starts acting on it.
 */
function my_theme_setup() {
	load_theme_textdomain( 'my-theme', get_template_directory() . '/languages' );

	// WordPress prints the title tag. Never hardcode one in header.php.
	add_theme_support( 'title-tag' );
	add_theme_support( 'automatic-feed-links' );
	add_theme_support( 'post-thumbnails' );

	add_theme_support( 'html5', array_map( 'trim', explode( ',', 'search-form, comment-form, comment-list, gallery, caption, style, script' ) ) );

	add_theme_support(
		'custom-logo',
		array(
			'width'       => 240,
			'height'      => 80,
			'flex-width'  => true,
			'flex-height' => true,
		)
	);

	add_theme_support( 'responsive-embeds' );
	add_theme_support( 'align-wide' );
	add_theme_support( 'editor-styles' );
	add_editor_style( 'assets/css/editor.css' );
}
add_action( 'after_setup_theme', 'my_theme_setup' );

Output is valid and updates as you type.

Tick what the theme supports and the generator writes the whole after_setup_theme block: the add_theme_support() calls, the HTML5 list, the logo arguments and any extra image sizes.

How to use

  1. Leave the title tag on. WordPress has printed it since 4.1, and a hardcoded <title> in header.php overrides every SEO plugin on the site.
  2. Keep featured images on unless the theme genuinely never shows one. Without it the panel is missing from the editor and editors assume something is broken.
  3. Add image sizes only for the sizes the theme uses. Each one is another file written on every upload, and they are not removed when you change your mind.
  4. Point the editor stylesheet at a real file inside the theme. A missing file fails quietly and the editor keeps the default styles.
  5. Paste the block into functions.php. It hooks itself to after_setup_theme.

Example

A classic theme with a logo, editor styles and one extra size:

function acme_setup() {
	load_theme_textdomain( 'acme', get_template_directory() . '/languages' );

	add_theme_support( 'title-tag' );
	add_theme_support( 'post-thumbnails' );

	add_theme_support( 'html5', array_map( 'trim', explode( ',', 'search-form, comment-form, gallery, caption' ) ) );

	add_theme_support(
		'custom-logo',
		array(
			'width'       => 240,
			'height'      => 80,
			'flex-width'  => true,
			'flex-height' => true,
		)
	);

	add_theme_support( 'editor-styles' );
	add_editor_style( 'assets/css/editor.css' );

	add_image_size( 'card-thumb', 480, 320, true );
}
add_action( 'after_setup_theme', 'acme_setup' );

add_image_size() only affects uploads made after it exists. Images already in the library keep the sizes they had.

Pitfalls

  • add_theme_support() on the wrong hook does nothing. after_setup_theme is the one; init is already too late for several features.
  • Adding an image size does not regenerate existing images. Old uploads fall back to the nearest size, which is usually the full one.
  • Every registered size multiplies upload time and disk use. Five extra sizes on a photo heavy site is a real bill.
  • add_editor_style() takes a path relative to the theme. An absolute URL is ignored, and so is a file that does not exist.
  • Declaring title-tag while header.php still prints its own gives you two title tags, and search engines read the first.
  • A child theme’s after_setup_theme runs after the parent’s, so parent support is already in place. Removing it needs remove_theme_support().
  • custom-logo without flex dimensions makes WordPress offer to crop every logo. Most people want flexible dimensions and a max size.
  • Block themes declare most of this in theme.json. Calling both is not an error, but theme.json wins where they overlap.

Compatibility

add_theme_support() has been in WordPress since 2.9. title-tag needs 4.1, responsive-embeds and align-wide need 5.0, editor-styles needs 5.0, and appearance-tools needs 6.0. Features your version does not know about are ignored rather than fatal. The generated code targets PHP 7.0 and up, and the tool runs entirely in your browser.

Frequently asked questions

Do I still need this in a block theme?
Mostly not. theme.json covers alignment, spacing and colours. post-thumbnails and the text domain are still worth declaring.
Why is my new image size not used?
It only applies to uploads made after you added it. Regenerate existing thumbnails with WP-CLI or a plugin.
Should I use appearance-tools?
Yes on WordPress 6.0 or later, if you want the design controls on. It replaces several separate calls with one.
Where does the text domain have to match?
The theme folder name, for translations from WordPress.org. Your own .mo files in /languages must use the same string.
What happens if I declare a feature twice?
Nothing harmful. The second call replaces the arguments of the first, which is how a child theme changes a parent’s logo size.

From the people who built this tool

WP Adminify

The WordPress admin, rebuilt: a dashboard worth looking at, menu and column control, a real file manager and the login page your client sees.

See WP Adminify Free version on WordPress.org

Weekly drops

New tools, when there are new tools

One email when something worth using ships. No schedule to fill, so no filler.

Your address goes nowhere else, and one click unsubscribes.