wp_get_theme() │ WP 3.4.0
Возвращает
- Name — название темы указанное в style.css;
- ThemeURI — УРЛ страницы шаблона;
- Description — описание темы;
- Author — автор темы;
- AuthorURI — УРЛ автора темы;
- Version — текущая версия;
- Template — (произвольно используется в дочерних темах) название папки родительской темы;
- Status — опубликована ли тема;
- Tags — метки используемые для описания темы;
- TextDomain — название, используемое при локализации темы;
- DomainPath — путь до файлов перевода темы;
Использование
$theme = wp_get_theme( $stylesheet, $theme_root );
$stylesheet(строка) Название каталога в котором находится тема, обычно оно совпадает с названием самой темы. По умолчанию название текущей темы.
По умолчанию: null $theme_root(строка) Полный путь до каталога в котором расположена тема. По умолчанию, путь получается функцией get_raw_theme_root().
По умолчанию: null
Примеры
#1 Демонстрация
Давайте посмотрим, как выглядит получаемый объект. Используем функцию на дефолтной теме twentyfourteen:
WP_Theme Object ( [theme_root:WP_Theme:private] => C:\sites\example.com\www/wp-content/themes [headers:WP_Theme:private] => Array ( [Name] => Twenty Fourteen [ThemeURI] => http://wordpress.org/themes/twentyfourteen [Description] => In 2014, our default theme lets you create a responsive magazine website with a sleek, modern design. Feature your favorite homepage content in either a grid or a slider. Use the three widget areas to customize your website, and change your content's layout with a full-width page template and a contributor page to show off your authors. Creating a magazine website with WordPress has never been easier. [Author] => the WordPress team [AuthorURI] => http://wordpress.org/ [Version] => 1.0 [Template] => [Status] => [Tags] => black, green, white, light, dark, two-columns, three-columns, left-sidebar, right-sidebar, fixed-layout, responsive-layout, custom-background, custom-header, custom-menu, editor-style, featured-images, flexible-header, full-width-template, microformats, post-formats, rtl-language-support, sticky-post, theme-options, translation-ready, accessibility-ready [TextDomain] => twentyfourteen [DomainPath] => ) [headers_sanitized:WP_Theme:private] => [name_translated:WP_Theme:private] => [errors:WP_Theme:private] => [stylesheet:WP_Theme:private] => twentyfourteen [template:WP_Theme:private] => twentyfourteen [parent:WP_Theme:private] => [theme_root_uri:WP_Theme:private] => [textdomain_loaded:WP_Theme:private] => [cache_hash:WP_Theme:private] => ea3ba1457a0fbfd275006de061bbffe5 )
How to Access Your WordPress functions.php File
Your WordPress functions.php file is key to adding code customizations to your WordPress site. It is especially useful if you are using a child theme and do not have access to the actual site files. There are two primary ways of accessing the functions.php file:
We recommend using a child theme instead of directly editing your site files.
Accessing functions.php through the WordPress Admin Interface
To access the functions.php file through your WordPress Admin interface, follow these steps:
- Log in to the WordPress Admin interface
- In the left sidebar, hover over Appearances , then click Theme Editor
- In the right sidebar, click functions.php
This will bring up the functions.php code editor. You can write code directly in this interface and save it.
Accessing functions.php through the Account Control Center
This process will not work on WP Enthusiast accounts since they do not have ACC file access. Instead, they may use SFTP to access files or access the functions.php file through the admin interface.
To access the functions.php file through your WordPress backend, follow these steps:
- Log in to the ACC
- In the left sidebar, click Files
- In the drop-down, click Web
- Locate your website’s directory and click the file path displayed to the right of it
Website directories on WP Hosting accounts may not be the same as your domain name. Visit the site’s details page to see where your site’s directory is mapped.