tools/add-theme-support-generator
Add Theme Support Generator
Declare what your theme supports in one after_setup_theme callback: featured images, HTML5 markup, post formats, a custom logo and the block editor's appearance tools — each emitted once, in the shape WordPress actually reads.
snippet.php
<?php
/**
* Theme support
*
* Generated by wp-skills.com
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Declares what this theme supports.
*
* Two things about where and when this runs.
*
* On after_setup_theme, and that is not a stylistic choice. WordPress reads
* most of these while it builds the admin and the front end, and one of them
* refuses to register late outright: add_theme_support( 'title-tag' ) called
* after wp_loaded raises _doing_it_wrong() and returns false, leaving
* current_theme_supports( 'title-tag' ) false and the theme without a <title>.
*
* And in the theme's functions.php rather than a plugin. Every callback on
* after_setup_theme runs in registration order, and a theme's functions.php is
* loaded after every plugin — so the theme's own calls run last and win.
* Measured: a theme declaring a plain post-thumbnails overrides a plugin's
* scoped one, and a theme's post-formats list replaces a plugin's outright.
*/
function wp_skills_theme_setup() {
add_theme_support( 'title-tag' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'menus' );
add_theme_support( 'responsive-embeds' );
add_theme_support( 'post-thumbnails' );
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'style',
'script',
)
);
}
add_action( 'after_setup_theme', 'wp_skills_theme_setup' );