/srv/www/example.com/current/web/app/themes/sage * get_stylesheet_directory() -> /srv/www/example.com/current/web/app/themes/sage * locate_template() * ├── STYLESHEETPATH -> /srv/www/example.com/current/web/app/themes/sage * └── TEMPLATEPATH -> /srv/www/example.com/current/web/app/themes/sage/templates */ add_filter('template', function ($stylesheet) { return dirname($stylesheet); }); add_action('after_switch_theme', function () { $stylesheet = get_option('template'); if (basename($stylesheet) !== 'templates') { update_option('template', $stylesheet . '/templates'); } }); /** * Sage includes * * The $sage_includes array determines the code library included in your theme. * Add or remove files to the array as needed. Supports child theme overrides. * * Please note that missing files will produce a fatal error. */ $sage_includes = [ 'src/helpers.php', 'src/setup.php', 'src/filters.php', 'src/admin.php' ]; array_walk($sage_includes, function ($file) { if (!locate_template($file, true, true)) { trigger_error(sprintf(__('Error locating %s for inclusion', 'sage'), $file), E_USER_ERROR); } });