Add theme support – basics
add_theme_support is very important functions for developing themes. Thanks to this function, you may add many cool features to your theme. And forget about title tag in your templates (since WordPress 4.1).
Important notice: add_theme_support must be called before “init” hook is fired, because it is too late for some features. Use “after_setup_theme” hook or just put functions calls straight in your functions.php file.
Example 1: functions.php
1 2 |
<?php add_theme_support('title-tag'); |
Example 2: after_setup_theme hook
1 2 3 4 5 6 7 8 9 |
<?php namespace MyTheme; $theme = new Theme(); add_action( 'after_setup_theme', [ $theme, 'after_setup_theme' ] ); class Theme { function after_setup_theme() { add_theme_support( 'title-tag' ); } } |