This is the main page for creating WordPress themes (templates). The basic information is taken from the official management and from personal experience.
To immediately see the general principle of creating a theme, go to the part of the tutorial: Creating the simplest theme
What is the Theme?
A WordPress theme is a set of css, js, php files that, in conjunction with WordPress and plugins, display information from the database on the screen in a beautiful and convenient form (design). Well, or in an ugly and inconvenient, it depends on which theme to choose … In other engines, the theme is also called a “template”, but in WordPress, it is customary to say the theme – theme, and not the template – template. Although both are essentially the same …
Thus, if you change the theme, then the site changes its appearance, it looks different. WordPress.org has thousands of free themes. Despite the wide selection of themes, many prefer to create their own themes. This is due primarily to the fact that creating a simple theme is not difficult.
To create a theme, you need only two files:
index.php– the main theme file, responsible for displaying content
style.css– main styles file, responsible for CSS styles
But not one theme, in fact, consists of just two files. There are more of them: PHP, language files, CSS and JS file, text files. The theme begins with two files, and then, to make it more convenient, it is expanded by adding files such as:
header.php– responsible for the output of the header
footer.php– is responsible for the conclusion of the basement
sidebar.php– responsible for the output of the sidebar
page.php– is responsible for displaying a separate page (a record)
- etc. See the full list.
The possibilities of the theme are essentially endless because there you can fully use PHP. BUT! The theme is designed to display the content of the site in a certain way, and not add functionality to the site. Therefore, it is customary to limit the capabilities of the theme to those that are responsible for the appearance, and all other features: voting, ratings, redirects, CEOs, etc. taken to plugins …
Thus, a theme can:
- Responsible for displaying site content for various types of devices: monitors and smartphones. Such themes are called adaptive. Also, themes can be fixed, single-column, two-column, etc.
- A theme can display any content;
- It can indicate what content will be displayed for different users;
- Can use any design elements (pictures, video).
Like on any site, the theme is not only a color scheme, layout, and a beautiful picture. Really high-quality themes are also very functional. The functionality of the theme lies in its flexible configuration. Those. it doesn’t add anything new to the site, but it is perfectly customized to the taste of the owner. For example, a background picture is set, the colors of the elements change, the menu and blocks with content (widgets) are configured.
How is the theme different from the plugin?
From the point of view of the code, we can say nothing – in the subject, you can create a full-fledged plugin. But in terms of logic – to everyone! The task of the plugin is to add something new to the site, for example, add a survey. The task of the theme is to display the contents, including this survey …
Thus, the theme is responsible for showing content on the page, and the plugin is needed to implement the functionality of the site.
Never add functionality to the theme itself unless there are good reasons for this. If you do this, then when you change the theme, functionality will be lost in a place with it. For example, your theme has a cool photo gallery. And if you change the subject, then this cool photo gallery will be lost …
Therefore, any functionality associated with editing / adding content to the site should be designed as a plugin.
Where to download Themes?
A theme catalog on WordPress.org. – One of the safest places to download themes. There, all Themes are checked for compliance with requirements and recommendations.
There are other sources, but themes there are usually paid. For example, themes can be downloaded from Creative Market.
Developing a theme start
Now that we have figured out the themes, you can begin to create your own theme. First thing you need:
- set up a local development environment.
- Then you can see examples of WordPress themes.
- Well, start developing your first theme.