GeneratorsDesignTheme Support

Theme Support Generator

The setup block every theme needs, with the feature flags you chose and the arguments each one really accepts — plus the image sizes and menus that belong beside them.

mytheme-setup.php
Saved just now
Theme kind
Features
Essentials
title-tag
Lets core print the title tag. Without it your theme has to, and plugins cannot filter it.
post-thumbnails
Featured images. Everything else here assumes it.
automatic-feed-links
Feed links in the head. Expected of every theme in the directory.
html5
HTML5 markup for search forms, comments, galleries and captions.
customize-selective-refresh-widgets
Widgets update in the customiser without a full reload.
Editor
wp-block-styles
Core block styles on the front end. Skip only if you style every block yourself.
align-wide
Wide and full alignment options in the block editor.
responsive-embeds
Embeds scale to their container instead of overflowing.
editor-styles
Load your editor stylesheet so the editor resembles the site.
appearance-tools
Spacing, border and typography controls without a full theme.json.
custom-line-height
Line height control in the editor.
custom-spacing
Padding and margin controls in the editor.
custom-units
rem, vh and vw as unit options.
Branding and media
custom-logo
A logo in the customiser, with a size you set.
custom-background
Background colour and image in the customiser. Rarely used now.
custom-header
Header image support, with dimensions.
post-formats
Aside, gallery, link, quote, video and audio formats.
woocommerce
Declares WooCommerce compatibility so the shop templates behave.
Image sizes
card-thumb640×360
crop
hero-wide1600×700
crop
width, height, crop — leave empty to skip set_post_thumbnail_size().
<?php
// Generated with WP CodeKit — powered by GrowQuest (https://growquest.io).
// Add to your theme's functions.php.

/**
 * Declare what this theme supports.
 */
function mytheme_setup() {
	load_theme_textdomain( 'mytheme', get_template_directory() . '/languages' );

	add_theme_support( 'title-tag' );
	add_theme_support( 'post-thumbnails' );
	add_theme_support( 'automatic-feed-links' );
	add_theme_support(
		'html5',
		array(
			'search-form',
			'comment-form',
			'comment-list',
			'gallery',
			'caption',
			'style',
			'script',
		)
	);
	add_theme_support( 'customize-selective-refresh-widgets' );
	add_theme_support( 'wp-block-styles' );
	add_theme_support( 'align-wide' );
	add_theme_support( 'responsive-embeds' );
	add_theme_support(
		'custom-logo',
		array(
			'height'      => 60,
			'width'       => 240,
			'flex-height' => true,
			'flex-width'  => true,
		)
	);
	add_theme_support( 'editor-styles' );
	add_editor_style( 'assets/css/editor.css' );

	set_post_thumbnail_size( 1200, 675, true );
	add_image_size( 'card-thumb', 640, 360, true );
	add_image_size( 'hero-wide', 1600, 700, true );
}
add_action( 'after_setup_theme', 'mytheme_setup' );

/**
 * Set the content width for oEmbeds and wide images.
 */
function mytheme_content_width() {
	$GLOBALS['content_width'] = apply_filters( 'mytheme_content_width', 1200 );
}
add_action( 'after_setup_theme', 'mytheme_content_width', 0 );

/**
 * Offer the custom sizes in the editor’s image size dropdown.
 *
 * @param array $sizes Size name => label.
 * @return array
 */
function mytheme_image_size_names( $sizes ) {
	return array_merge(
		$sizes,
		array(
			'card-thumb' => __( 'card-thumb', 'mytheme' ),
			'hero-wide' => __( 'hero-wide', 'mytheme' ),
		)
	);
}
add_filter( 'image_size_names_choose', 'mytheme_image_size_names' );