E
E
espinal2019-03-02 17:10:13
CMS
espinal, 2019-03-02 17:10:13

How to create a theme for WordPress?

Designed a "website": html+css+js. I wanted to transfer it to the CMS (since I have no experience with server languages, to write a back).
I looked at a bunch of lessons and re-read a lot of literature (really a lot). I did not find a universal explanation.
I already asked a question here, people advised MODX but there are even fewer clear lessons on it.
How to make a template, theme for CMS, having a ready-made site (only made up)?
.php not be able to... Are there any standard expressions suitable for any typed pages?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dima Polos, 2019-03-02
@espinal

Creating a theme or "stretching" the layout on the CMS is not just a matter of transferring markup from one file to another. Often this is the implementation of the functionality that is displayed in the layout.
For example, if there is a block with phone numbers in the header, then you need to consider how these numbers will be added from the admin panel, and how to display them. If there is a block in the Latest News layout with article cards, then when creating a topic, you need to somehow organize the collection of the latest posts and then display them. In this regard, WP has, of course, ready-made solutions, but often if you take them out of the box, then they are displayed with the layout that the WP developers provided, otherwise you either need to redo your layout or delve into how the ready-made solution works and somehow change it. So without PHP it will be hard. If you don’t need anything non-standard, then everything is quite simple.
A WP theme consists of css styles, and php template files, as well as a functions.php script, which is more about functionality. You can create a theme from scratch, or inherit from some ready-made one, and redefine templates and styles in it.
The theme's main file, oddly enough, is style.css. First, create a new directory in the /wp-content/themes/ folder, create a style.css file in it, and add a comment to this file:

/*
Theme Name: Имя темы для админки
Author: себя любимого сюда
Text Domain: свои контакты для плюсиков в карму
*/

If you want to inherit from another theme, you need to add another Template: and specify the name of the theme, or rather the folder where the theme is located.
/*
Theme Name: Имя темы для админки
Author: себя любимого сюда
Text Domain: свои контакты для плюсиков в карму
Template: twentyseventeen
*/

Further, if you need to redefine the template, just create a file with the same name in your folder, it will be taken as a priority. The only thing is there is a nuance with functions.php, since the parent one is executed before yours.
Working from scratch, without inheritance, you also need to add the index.php, header.php, footer.php and screenshot.png files, it will be displayed in the admin panel as a theme preview, the latter, if I'm not mistaken, is not necessary. The header.php file is responsible for displaying the header, footer.php - for the footer. index.php is responsible for all requests UNLESS there is a better template file. 404.php is responsible for the 404 error. page.php is responsible for displaying a page (you can create separate pages in WP), category.php for displaying a category page, single.php for displaying a single post, and so on. More
Templates can be created more flexibly, for example, for a specific post type, or for posts that have a different output template set in the admin panel, more about theme files here .
WP has a system of widgets and plugins that greatly expand the capabilities of the engine. WP offers registration for its taxonomies, post types, and more. Look at the site that gave the links above, and also gave a link to the codex wprdpress above in the answers.
As for other CMS, they correctly noted that each in its own way, for example, OpenCart uses the Twig template engine, and the engine itself is written in MVC, that is, the functionality is separated from the display, so it’s easier to edit templates in it, they have almost one html, WP is worse, that’s all mixed with php.
PS: when creating a theme, there are still many subtleties, for example, to connect your styles, your js, you need to know the concept of hooks, and connect scripts and styles through function calls, which in turn must subscribe to events, that is, hooks ... So, wp is not the easiest option if all these concepts are far from being understood, but there are articles , videos , docks . Good luck!

S
Sanes, 2019-03-02
@Sanes

Without knowledge of PHP only Modx. Documentation and lessons in Russian through the roof.

S
Stanislav M., 2019-03-02
@StanislavMychko

It all depends on the template engine that is used in the CMS. But that's how I see the Wordpress tag in the question.
WordPress themes are quite easy to implement.
Any theme is divided into standard blocks (site header, footer, menu, sidebar, etc.). Files with names are created in accordance with these blocks. There are some peculiarities, but they are indicated in the documentation.
You understand - one and the same theme (template) designed by you for different CMS needs to be "assembled" in different ways in accordance with your own rules.
For example, the link for Wordpress Theme Creation

K
Kirill Arutyunov, 2019-03-02
@arutyunov

What is your goal of transferring layout to CMS? Make a task for yourself or for a customer? If for the customer, look for someone who will turn the layout into a theme. If done without frills and simply, then work for 1-2 days. If you need to learn, then you will have to deal with the server language a little. Take a standard WordPress theme and remake it to your layout. If you need to manage the site, then why not just work with HTML? How often do you need to change information?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question