Заголовки style.css
Это особенный файл — именно по нему WordPress идентифицирует тему. Когда вы заходите в раздел Темы в админке, WordPress просматривает все папки в каталоге themes на наличие в них файла style.css . Те папки в которых найден style.css с заголовком Theme Name: определяются как папки тем. Название темы и другие данные берутся из файла style.css . Такие данные считываются из данных в начале файла (они находятся в комментариях):
/** * Theme Name: Моя первая темы */
Весь список параметров файла style.css
Вместе с полем Theme Name можно указать и другие поля. Theme Name(обязательное) Название темы. это обязательное поле! Достаточно только указать это поле, чтобы ВордПресс определил тему. Остальные поля не обязательны, но желательны. Template Название родительской темы. Пример: Twenty Seventeen. Description(обязательное для репозитория WP) Краткое описание темы. Theme URI URL страницы, где можно найти дополнительные сведения о теме. Author(обязательное для репозитория WP) Имя лица или организации, разработавшей тему. Рекомендуется указывать имя пользователя на сайте wordpress.org. Author URI URL — адрес автора или организации. Version(обязательное для репозитория WP) Версия темы, в формате X.X или X.X.X . License(обязательное для репозитория WP) Лицензия темы. License URI(обязательное для репозитория WP) URL лицензии. Text Domain(обязательное для репозитория WP) Строка, используемая как textdomain при переводе перевода. Domain Path Путь до файла MO перевода относительно папки темы. Используется чтобы WordPress знал, где найти перевод, когда тема отключена. По умолчанию /languages . Tags Слова или фразы, черзе запятую, позволяющие пользователям находить тему с помощью фильтра тегов. Полный список тегов приведен в руководстве по обзору темы. обязательное для репозитория WP — это значит что поле обязательное если вы планируете размещать тему в каталоге (репозитории тем) WordPress.
Пример полного заголовка файла style.css
/** * Theme Name: Название темы * Theme URI: URL темы в каталоге WordPress или где-то еще. Пример: http://wordpress.org/themes/twentythirteen * Author: Имя автора темы * Author URI: URL автора. Пример: http://mysite.org/ * Description: Короткое описание темы. * License: Лицензия. Пример: GNU General Public License v2 or later * License URI: URL на лицензию. Пример: http://www.gnu.org/licenses/gpl-2.0.html * Tags: Метки темы, по которым тему можно будет найти в каталоге WordPress. Например: black, brown, orange, tan, white, yellow * Text Domain: Домен перевода для темы. Нужен чтобы можно было перевести описание указанное в Description. Например: twentythirteen * Version: Версия темы. Пример: 1.0 */
Содержимое файла style.css в корне темы CMS WordPress
Базовая информация файла style.css. Пример, какие параметры и данные нужно указывать в корневом файле style.css для указания информации о шаблоне CMS WordPress.
/* Theme Name: Twenty Twenty Theme URI: https://wordpress.org/themes/twentytwenty/ Author: the WordPress team Author URI: https://wordpress.org/ Description: Our default theme for 2020 is designed to take full advantage of the flexibility of the block editor. Organizations and businesses have the ability to create dynamic landing pages with endless layouts using the group and column blocks. The centered content column and fine-tuned typography also makes it perfect for traditional blogs. Complete editor styles give you a good idea of what your content will look like, even before you publish. You can give your site a personal touch by changing the background colors and the accent color in the Customizer. The colors of all elements on your site are automatically calculated based on the colors you pick, ensuring a high, accessible color contrast for your visitors. Tags: blog, one-column, custom-background, custom-colors, custom-logo, custom-menu, editor-style, featured-images, footer-widgets, full-width-template, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready, block-styles, wide-blocks, accessibility-ready Version: 1.3 Requires at least: 5.0 Tested up to: 5.4 Requires PHP: 7.0 License: GNU General Public License v2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Text Domain: twentytwenty This theme, like WordPress, is licensed under the GPL. Use it to make something cool, have fun, and share what you've learned with others. */
Расшифровка
Параметры помеченные звездочкой — обязательны для использования в теме.
- Theme Name (*): Name of the theme.
- Theme URI: The URL of a public web page where users can find more information about the theme.
- Author (*): The name of the individual or organization who developed the theme. Using the Theme Author’s wordpress.org username is recommended.
- Author URI: The URL of the authoring individual or organization.
- Description (*): A short description of the theme.
- Version (*): The version of the theme, written in X.X or X.X.X format.
- Requires at least (*): The oldest main WordPress version the theme will work with, written in X.X format. Themes are only required to support the three last versions.
- Tested up to (*): The last main WordPress version the theme has been tested up to, i.e. 5.4. Write only the number, in X.X format.
- Requires PHP (*): The oldest PHP version supported, in X.X format, only the number
- License (*): The license of the theme.
- License URI (*): The URL of the theme license.
- Text Domain (*): The string used for textdomain for translation.
- Tags: Words or phrases that allow users to find the theme using the tag filter. A full list of tags is in the Theme Review Handbook.
- Domain Path: Used so that WordPress knows where to find the translation when the theme is disabled. Defaults to /languages .
After the required header section, style.css can contain anything a regular CSS file has.
Style.css for a Child Theme
If your theme is a Child Theme, the Template line is required in style.css header.
/* Theme Name: My Child Theme Template: twentytwenty */
Базовые стили и классы, которые используются движком WordPress
/* =WordPress Core -------------------------------------------------------------- */ .alignnone < margin: 5px 20px 20px 0; >.aligncenter, div.aligncenter < display: block; margin: 5px auto 5px auto; >.alignright < float: right; margin: 5px 0 20px 20px; >.alignleft < float: left; margin: 5px 20px 20px 0; >a img.alignright < float: right; margin: 5px 0 20px 20px; >a img.alignnone < margin: 5px 20px 20px 0; >a img.alignleft < float: left; margin: 5px 20px 20px 0; >a img.aligncenter < display: block; margin-left: auto; margin-right: auto; >.wp-caption < background: #fff; border: 1px solid #f0f0f0; max-width: 96%; /* Image does not overflow the content area */ padding: 5px 3px 10px; text-align: center; >.wp-caption.alignnone < margin: 5px 20px 20px 0; >.wp-caption.alignleft < margin: 5px 20px 20px 0; >.wp-caption.alignright < margin: 5px 0 20px 20px; >.wp-caption img < border: 0 none; height: auto; margin: 0; max-width: 98.5%; padding: 0; width: auto; >.wp-caption p.wp-caption-text < font-size: 11px; line-height: 17px; margin: 0; padding: 0 4px 5px; >/* Text meant only for screen readers. */ .screen-reader-text < border: 0; clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute !important; width: 1px; word-wrap: normal !important; /* Many screen reader and browser combinations announce broken words as they would appear visually. */ >.screen-reader-text:focus < background-color: #eee; clip: auto !important; clip-path: none; color: #444; display: block; font-size: 1em; height: auto; left: 5px; line-height: normal; padding: 15px 23px 14px; text-decoration: none; top: 5px; width: auto; z-index: 100000; /* Above WP toolbar. */ >
Итак, суть проблемы — на сайте создано или импортировано большое количество пустых постов без контента….
Этот пост вытащил из многолетних черновиков, поэтому особо расписывать не буду. Просто юзайте код. Итак,…
Задача простая — добавить на сайте в виджетах или даже на отдельной странице ленту из…
Бывает такая ситуация, что the_date() выводит дату только у первого поста, если остальные записи имеют…