Hardware and software setup

Is it possible to edit files in the wp-includes folder? Understanding the Internal Functioning of WordPress WordPress Structure.

The permissions set on files and folders owned by the WordPress content management system have a very serious impact on the security of the site. If you give the wrong permissions, then you can expect a variety of errors in the functioning of the site, whether it's a white screen of death instead of a page, or the inability to upload images to the media folder. Moreover, incorrectly set access rights can destroy the entire security system of the site, making it extremely vulnerable to hacker attacks.

WordPress has a well-defined directory structure where the central folders are wp-content, wp-admin, and wp-includes.

Almost all important components, which are part of your site, such as themes, plugins, etc., contain these three folders. At the same time, they have their own access rights, allowing the administrator to decide "who" and "what" can do in them. By "who" here is meant a user who will have the following resource associations:

  • Owner - direct ownership;
  • Group - ownership through membership in a group;
  • Others are lack of ownership and group.

Web server users and their groups

Before we continue to parse access permissions in WordPress, it is advisable to understand who is meant by the user of the web server, since everything revolves around him. In short, this is a regular account that has rights to perform some actions on the web server. Take, for example, the transfer protocol FTP files. As soon as you need to upload any image via FPT, you will use the appropriate account.

But an FTP account is needed only when you need to upload something directly to the server, but if you need to go, for example, to the admin panel? In this case, a web user account comes into play, allowing you to manage the site on WordPress, installing plugins and themes, uploading images through the multimedia manager, etc. It is in his name that new files are created when you do these things in your admin panel.

Any individual user can also be a member of a group that has its own privileges. Since they apply to everyone in the group, this is the best way to assign privileges to a specific resource and share them among all members.

Some web hosts, mostly based on Cpanel, do not distinguish between accounts. However, there are also hosts where these types of users are different, although they belong to the same group. Through existence different types users, you have the ability to set up the correct access control for your site.

File Action Permissions WordPress

Any resource in WordPress is associated with a specific set of predefined values ​​that dictate what the user can do with it. There are three actions that we can perform on a particular resource - read, write (or modify), and execute. For each resource, it is possible to specify which of these actions can be performed by the owner, group, and others. Thus, we need three bits (one for each action) for each association, for a total of 9 bits. Therefore, the resolution becomes a three-digit number, such as 664, in which:

  • 6 - actions for the owner;
  • 6 - actions for the group;
  • 4 - actions for other types.

At the same time, each value of these numbers determines all the possibilities that given type users. In the case of 664, 6 is read/write only and 4 is read only.

Catalogs

Directories, like files themselves, can also be subject to certain access rights. They are very similar, but still have some differences, such as:

  • Read - view the contents of the directory;
  • Write - create new ones and delete existing ones (at the same time, the rights for the directory apply to everything that it contains);
  • Execute - go into directories (for example, using the command in the terminal).

Setting the right limits is vital because it's about security and not just WordPress functionality. Take, for example, config.php, it is desirable to set a hard limit of 600 (read-only). Let's assume that his permissions change to 666, then anyone can see and change the configuration of your site, which means they can easily break it or make it vulnerable to external threats.

Changing Action Permissions in WordPress Directories

Your hosting cpanel provides an interface where you can set any access level for stored resources. Most often, this can be done by simply selecting a specific file and clicking Change Permissions. If you are dealing with a terminal, it will be easier to use a special chmod command. It looks like this: chmod 644

Now that we have already covered the basic concepts, we can proceed directly to setting permissions on WordPress resources. They can be different, depending on the desired level of security and ease of use. Some make them stiffer, while others are too soft. In this case, the most important thing is to achieve the greatest security without creating obstacles for normal functioning WordPress. In general, it is recommended to do the following:

  • Put on all files 664;
  • To all folders 775;
  • wp-config.php should only be 600.

Here's what happens:

  • Accounts will be able to read and modify files;
  • The engine itself will be able to create, modify or delete any files;
  • wp-config.php will be completely protected from prying eyes.

Keep in mind that contrary to the default WordPress configuration, a particular server may be stricter than others and will not allow wp-config.php to be set to 600. But you can give it a softer 640, and if that doesn't work, even 644.

In general, it's safest to set everything to read-only. Thus, it will be very difficult for hackers to upload malicious scripts to your site or modify existing ones. This will greatly reduce the scope for any attacks. However, if you put on absolutely everything “read-only”, then there may be some problems in usability.

For example, you will no longer be able to upload media files, as well as install new plugins and themes. Also, under some circumstances, such strict permissions can lead to weird errors when updating plugins or WordPress core. Therefore, the recommended defaults will work best for most tasks.

Conclusion

And so, we have considered the important role played by permissions for accessing WordPress resources. If they are set correctly, then this can significantly increase the security of your site, otherwise you can get a lot of problems, including very serious ones, both with security and with the overall performance of WordPress. Keep in mind that you can also set restrictions on WordPress resources through htaccess, but this will be a little more complicated.

Hello dear readers! Today I decided to touch on a very important issue of the WP action algorithm when interacting with templates. This is relevant, since understanding the nuances of the engine's work with the files responsible for the component parts will allow you to quickly and correctly make the necessary changes.

In the future, you will repeatedly have to edit an existing one or create a new page on your blog or website, I assure you. Even if you successfully install a particular theme, there is absolutely no guarantee that everything will suit you. And if suddenly you are immediately satisfied with everything, over time you still want to correct something or radically change it.

In the end, knowledge is never superfluous, it will save not only precious time, but also your money, since you can do the most necessary, urgent and requiring prompt intervention yourself, and not turn to specialists for every little thing.

How to Install a Theme and Edit WordPress Templates

If you follow the link given at the very beginning of this publication, you will learn how to activate the default themes in, as well as how to download them from third-party resources and install them through the same administrative panel.

However, if you want to comprehend the whole essence of working with the site and gain additional knowledge, then you should try downloading and installing the theme first using some FTP client(I, for example, use ).

This program allows you to perform any actions with files located both on local computer, and on a remote hosting server (and read about what it is and how to get a place for your project), where your site "lives".

I have already given my recommendations on where it is better to choose free and paid themes (in the same material, a link to which is presented at the beginning of the article). Briefly, I note that it is desirable to download from official sites, for example, from here or from here. First, download the theme to your computer, and then follow these steps:

  • Unzip the archive by clicking on it right click mouse and selecting the appropriate operation;
  • After gaining FTP access to your site files, upload the folder obtained after unzipping to the hosting in directory (folder) themes

Basically, after that, the WordPress theme is installed. In order to connect the design to your site, you only need to activate it in the control panel. In the future, it will be possible to edit page template files through the same admin panel by going to the section "Appearance" - "Editor":

There, on the right side, there is a list of all the templates included in this theme. In the future, if necessary, you can use this editor to change the appearance of the pages of your site. But! Initially, I do not advise using this tool, especially for beginners, because in case of any mistake, you can easily "put" your site down, after which you can spend a lot of time and nerves looking for the cause.

Much more convenient from this point of view, which also establishes an FTP connection, has syntax highlighting, and in case you make a mistake, it allows you to return the original contents of the files in several steps. However, judge for yourself. Here is the view of the web page in the template editor section of the WordPress admin:


And here is the editing interface that Notpad Plus Plus offers:


As you can see, the difference is obvious, and even with a cursory comparison third party editor wins by an overwhelming margin. Well, when you try all the functionality of Notepad ++, all remaining doubts will be completely dispelled.

And further. Editing WordPress templates I advise to carry out local server, that is, on your computer (here Denver, and even better, Open Server will help you). We made all the necessary changes, tested it, and then upload the files to the hosting. Experimenting with a "live" site can be expensive.

File structure of page templates

Now let's look at what files and templates can be included in the downloaded theme, the task of which is to determine the face of your project, that is, the appearance of all its pages displayed in the browser. After installing the theme, you will get the path to its directory:

your_site/wp-content/themes/your_theme_name

For my blog in a folder with one of established themes this path looks like this:

Website/wp-content/themes/country

When viewed in the Notpad++ editor window, the folder with all the files in your WordPress themes will look like this:

The structure includes files with the .php extension, among which it is possible to single out exactly templates designed to display entire pages, which are the main ones, that is, they are present in almost any theme, such as the main (index.php), post page (single.php), static pages (page.php).

However, there are templates that are responsible for displaying a specially crafted web page. For example, on my blog at one time existed on the page, in order to install it, the mail.php file was created.

In addition, there are templates that are needed to design individual parts displayed on all pages of the site. This is a header, or header (header.php), left and / or right column, otherwise sidebar (sidebar.php), footer, or footer (footer.php). Schematically, such a design with page areas can be represented as follows:


As you can see from the screenshot, if the header, sidebar, footer on any page look the same, it will depend on the type of web page, which will be determined by the corresponding file with the .php extension.

At the present stage, the WordPress engine allows you to display different content in the footer, header and sidebar on the main, static and post pages, and some modern themes allow you to customize this through the admin panel.

WordPress Template Hierarchy and Page Sequence

I’ll try to briefly go over the points and explain in what order it displays this or that web WordPress page, considering its place in the hierarchical scale of priorities.

The point is that in each theme initially has its own set of files, some of the common ones may be missing. For example, there may not be a category.php template that is responsible for displaying categories (categories). In this case, WordPress interacts with the index.php file and the design of the category page will be exactly the same as the main one.

Let's start with the home page. Priority is given here Home. That is, the sequence in which WordPress will interact with the template is as follows: the Home request occurs first, if it is not there, then WordPress refers to main template Index:

  1. Home (top priority);
  2. index.

If a single blog post is being constructed, whose default template is Single, then the sequence will be:

  1. Single-(post_type). Let's say if in a particular case the post type is product, then WP will refer to the single-product.php template;
  2. single;
  3. index.

For a static page Page the hierarchy is as follows:

  1. Custom template (a custom template that is created specifically for a specific web page);
  2. Page-(slug). Here slug is the short name (alias) of the page. For example, if the theme contains a file called page-recent-news, then WP will refer to it;
  3. Page-(id). If a web page is identified by a specific identifier (id) 12, then it will be the next one in the hierarchy, if the above are not available;
  4. Page;
  5. index.

To display the categories page, WordPress will undertake a search special file, then will search by id. If such templates do not exist, then generic Category template, then in descending order Archive and Index:

  1. Category-(slug);
  2. category-(id);
  3. category;
  4. Archive (archive);
  5. index.

A similar picture emerges for the tag (label). First of all a special template, then based on id, after that Tag, Archive and Index:

  1. Tag-(slug);
  2. Tag-(id);
  3. archive;
  4. index.
  1. author;
  2. archive;
  3. index.

Let's move on, there's not much left. It is possible to have a temporary archive page Date. In this case, WP will look for Archive after it fails, followed by Index:

  1. date;
  2. archive;
  3. index.

The vast majority of resources use a search page, which is determined by a template Search. In case of its absence - the file of the main template Index:

  1. search;
  2. index.
  1. index.

Finally, it's possible that the theme you've installed has a separate web page for displaying the products of various applications (video, audio, images). In this case, the template hierarchy is as follows:

  1. Image, video, audio;
  2. application;
  3. attachment;
  4. index.

That's all for today. This post could be Starting point to understand how WordPress works and the basis for subsequent articles on this topic. Therefore, you are welcome to subscribe to fresh publications that promise to be very interesting and informative. And finally, as usual, the video:

If you want to use the full potential of WordPress, then you definitely need to learn more about templates. When WordPress renders a page, it uses templates to determine how things should look. Moreover, CMS adheres to a strict hierarchy, thanks to which everything looks organized and harmonious. Knowing what the WordPress template hierarchy is and how it works will help you fine-tune the theme of your site.

The WordPress template hierarchy consists of seven main categories:

  1. home page of the site
  2. Single entry
  3. Static page
  4. Categories and Tags Page
  5. Custom Post Types
  6. Search results page
  7. Page 404 (nothing found)

In this guide, we will introduce you to WordPress templates and their hierarchy. We'll also explain how themes use template files to display your site's pages. We have a huge field for activity, so let's start working on it!

Introduction to template files (and how they relate to WordPress themes)

When you create a simple static website, you usually just use HTML and CSS to render and customize its appearance. WordPress, on the other hand, is much more powerful. The platform is built in PHP and it uses several special .php files to define how the individual parts of your site pages are formed.

For example, look at the right side of this post. There is a sidebar that points to other related posts from our blog. When your browser told WordPress to load this article, several template files were pulled up at the same time, one of which is called sidebar.php This file contains information on how to display the sidebar you see now and what elements it should include:

The sidebars are, of course, only one of the parts full page. Most WordPress pages require several template files to work, including:

  • index.php
  • header.php
  • sidebar.php
  • footer.php
  • functions.php
  • single.php
  • comments.php

It should be noted that these are not all template files that you can find in WordPress. header.php, sidebar.php And footer.php, are especially important because they are known as 'template partials'. This means that they can be embedded in other templates.

The WordPress approach to creating pages can seem daunting at first. However, this approach is quite effective. If you had a unique template for every single page on your site, customization would be a nightmare. The modular approach to WordPress templates allows you to make changes to a single file and use that element anywhere on the site.

When it comes to choosing templates for each page, the first thing WordPress does is check your current theme. Each theme includes its own set of template files, which will take precedence over all others. This is part of what we call the ‘WordPress Template Hierarchy’ in action, which we will cover in the next section.

Now that you understand how WordPress renders your pages, it's clear that themes are basically a collection of template files. In practice, only one template file is required for a theme, and that is − index.php. However, most themes include many more templates. For things that aren't covered in the chosen theme, WordPress goes back to other files in its hierarchy to fill in those gaps.

How the WordPress Template Hierarchy Works

In the previous section, we introduced you to some sample WordPress template files. However, these were just some of the templates that can be used when loading a page or post. The WordPress template hierarchy determines which templates are used and in what order.

For example, if you try to load a page for an abstract category hosting, then this is what will happen in the background:

  1. WordPress will look for a template file called category-hosting.php in the current theme directory.
  2. If the file category-hosting.php will not be found, WordPress will look for one that uses the category id, e.g. category-2.php.
  3. If WordPress doesn't find any of these options, it will look for common file categories.php.
  4. If a file named categories.php not found, WordPress will roll back and look for the template archive.php.
  5. Finally, if all other actions fail, the platform will download the file index.php your theme and will use it as the page template.

Some template files always take precedence over others, so they are organized in a hierarchy. In a broad sense, WordPress sites consist of seven categories of pages, each of which has its own well-defined hierarchy. Now let's look at what these categories are and how their hierarchies work.

WordPress Template Hierarchy Explained (7 Categories)

The pages of each WordPress site can be divided into seven categories. Each of these categories has a built-in hierarchy, and we'll walk you through each one.

1. Main page of the site

First of all, let's talk about the first (main, home) page of your site. When WordPress loads the main or home page, the first thing it will look for is the file front-page.php. If this file is not available, the platform will fall back to home.php. If both files are missing, WordPress will refer to the always trusted file index.php, which is always there (otherwise your theme won't work).

In other words, this hierarchy is subdivided as follows:

  1. front-page.php
  2. home.php
  3. index.php

Even if these three files are the same, WordPress will still follow its internal logic. Of course, this particular hierarchy is quite simple. Let's move on to the category of pages, which is a bit more complicated.

2. Single entry

WordPress articles (like this one) fall under the single post category. At the beginning of this section, we talked about some of the template files involved in generating a record. However, these were mostly internal elements. Before WordPress can render them, it must determine which template file to use for the page as a whole.

Here's how the single entry hierarchy works:

  1. single-(post-type).php
  2. single.php
  3. singular.php
  4. index.php

You probably won't recognize some of these template files, so let's give them some context. Top of the list single-(post-type)-(slug).php. A clearer example would be single-product-ca-12.php, in the case of an online store. In other words, WordPress will look for a unique template file for every post you upload within its specific category. If the platform cannot find a suitable template, it will fall back one step to single-(post-type).php and so on, until it inevitably reaches again index.php.

In practice, this approach allows you to create custom templates for individual posts or products. However, if you prefer to use one WordPress template for all your posts, this requires single.php.

3. Static page

Statically, pages fall into a separate category in WordPress. For example, take the Hostinger site as a whole. https://www.website is our main page, and when accessed, the template is loaded front-page.php. Other sections of the site, such as https://www.site/kupit-hosting-sajtov, are categorized as static pages.

Static pages implement the following hierarchy:

  1. Custom template file
  2. page(slug).php
  3. page-(id).php
  4. page.php
  5. singular.php
  6. index.php

Note that the first item in the list is not a filename. This is because WordPress can recognize multiple content types as static pages. For example, if you are dealing with a post, WordPress will by default use the hierarchy we talked about earlier. Static pages on the other hand (such as /kupit-hosting-sajtov) will navigate directly to page-slug.php. In our example, this will be page-kupit-hosting-sitev.php(if such file exists).

From now on, this hierarchy works in the same way as with records. If there is no template for a unique page structure, WordPress will look for one that matches its ID, and so on. As always, in the end all paths lead to index.php if you don't find a solution in the earlier steps.

4. Category and tag pages

As you remember, we actually looked at the category hierarchy earlier in this article as an example. In any case, let's break down the patterns that this hierarchy covers in order:

  1. category(slug).php
  2. category-(id).php
  3. categories.php
  4. archive.php
  5. index.php

This hierarchy works the same as for single posts and static pages. WordPress will look for a template that is unique to the category you want to upload, first by the filename, which includes its special slug part, and then by its id. If this approach fails, it will work with categories.php, and then archive.php. After all, your WordPress archive should include posts from all of your categories, so it makes sense to include it in that particular hierarchy.

In this section, we also mention WordPress tags because both categories and tags are taxonomic elements. Also, their hierarchies are exactly the same, except that you replace all instances of the ‘ category' on the tag ‘ tag', and then - category-(slug).php becomes tag-(slug).php etc.

5. Arbitrary (custom) post types

If you're not familiar with then it makes sense to note that this type of content mostly doesn't fall under the default WordPress classifications. For example, if you start a blog that focuses on reviews, you can create a custom post type called reviews ( reviews), and customize it to include additional features.

However, creating custom post types is a topic for another tutorial. On the this moment suffice it to say that these content types have their own hierarchy:

  1. archive-(post_type).php
  2. archive.php
  3. index.php

As you can see, this hierarchy is not as clear-cut as some of the others. However, there are still several levels of templates before moving on to index.php, which is enough to create complex pages.

6. Search results pages

  1. search.php
  2. index.php

In this case, WordPress will go directly to index.php if it can't find a custom template for your search results page. However, most modern themes will include some customization for your search page.

7. Page 404 (nothing found)

The 404 page is an error page. You usually hope your users never see these pages, but it's still important to take care of them just in case. WordPress doesn't include custom error pages out of the box, but they're easy enough to install.

If you create your own error page, WordPress will look for it first, as shown in this hierarchy:

  1. 404.php
  2. index.php

In our opinion, it's worth taking the time to create a custom error page if your site has a lot of traffic. This way, your users won't be scared off on those rare occasions when an error occurs.

The WordPress Template Hierarchy in Action

In this final section, we'll take a look at how the WordPress template hierarchy might work in a real-world situation. We will use a hypothetical site as an example.

Imagine that you have created a website that includes a home page, a couple of static pages, and a lot of posts. You are also using a custom theme which includes these template files:

  • index.php
  • home.php
  • page.php
  • archive.php
  • categories.php

This is a small and neat collection of template files, but more than enough to get the site going. In this case, if you were to visit the home page, WordPress would load the template home.php.

Below are examples of other pages you may visit and the template files they will use:

  • Random entry would load index.php as a template file because there are no other templates in the hierarchy in question.
  • Any category visited will use the template file categories.php, since such a WordPress template is available. If it didn't exist, WordPress would load it instead. archive.php.
  • Your static pages will use page.php, but they will default to index.php if the first file is not available.
  • Since there is no error page among the templates, WordPress will use index.php as a template in this situation.

Many examples could be given, but given example should give you an idea of ​​how such a site would work. Which WordPress templates will be used is determined by the theme settings and hierarchies we talked about earlier. We hope that this manual will serve as a good starting point if you need to work with the WordPress template hierarchy in the future.

Conclusion

The WordPress template hierarchy may seem daunting at first glance. However, in the sections above, we have outlined which template files take precedence over each other. With this information, you will know exactly which files you need to fix if you want to make changes to your current WordPress theme.

Do you have questions about the WordPress template hierarchy and how they work on your site? Ask a question in the comments section below!

Hello friends. Very often, when answering questions from readers, one has to face the fact that when asking questions about the various functionality of themes or plugins, many do not even present the basic structure of their site on the server. It's amazing, but true. In this article, we're going to go over the basics of the most important, standard WordPress folders, with a focus on the root files that actually run your site.

WordPress directory structure

The file structure of WordPress is very simple. Do you have a folder public_html, where there are usually three key folders, as well as many others important files, including wp-config.php And .htaccess

To access files and folders you can use file manager cPanel from your hosting service or any regular

For this review, we will be using the most popular ftp client, FileZilla. This is what the folder should look like public_html inside:

Before we get into these top three folders, let's take a look at the files that lie inside public_html for no reason. First of all, this is .htaccess, with which you can control the structure of permalinks, files and folders, as well as manage access rights to them in your WordPress installation. Here's what it looks like standard file .htaccess without any changes:

# BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %(REQUEST_FILENAME) !-f RewriteCond %(REQUEST_FILENAME) !-d RewriteRule . /index.php [L]# END WordPress

Then there is a file which represents your homepage by default, unless it is replaced by pages like front-page.php or home.php:

Another required file in this directory is wp-config.php. This file allows you to set the basic configuration of WordPress, including settings for the database MySQL, secret keys, and database prefix information. This is what your database settings should look like:

// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define("DB_NAME", "notrealname"); /** MySQL database username */ define("DB_USER", "notrealuser"); /** MySQL database password */ define("DB_PASSWORD", "notrealpassword"); /** MySQL hostname */ define("DB_HOST", "localhost");

Other notable files in this directory are wp-activate.php, And wp-signup.php, which are collectively responsible for the registration, authorization, and user registration confirmation process. File wp-comments-post.php is responsible for the commenting function and the prevention of content duplication, while wp-settings.php is responsible for setting some WordPress variables.

As the name of the folder implies, this is where the admin tools are located. For example, admin.php(the heart of this folder) allows you to link the installation to a database, displays the WordPress dashboard, and offers other key features, such as, for example, checking if a given user is an administrator. If the user is an admin, then file usage is enabled wp-load.php which in turn downloads the file wp-config.php:

/** * In WordPress Administration Screens * * @since 2.3.2 */ if (! defined("WP_ADMIN")) ( define("WP_ADMIN", true); ) if (! defined("WP_NETWORK_ADMIN")) define( "WP_NETWORK_ADMIN", false); if (! defined("WP_USER_ADMIN")) define("WP_USER_ADMIN", false); if (! WP_NETWORK_ADMIN && ! WP_USER_ADMIN) ( define("WP_BLOG_ADMIN", true); ) if (isset($_GET["import"]) && !defined("WP_LOAD_IMPORTERS")) define("WP_LOAD_IMPORTERS", true); require_once(dirname(dirname(__FILE__)) . "/wp-load.php");

If you pay attention to the names of these files, you will understand that most of them tell the user about the functions they perform, which you are familiar with from the WordPress admin. For example, profile.php displays the user profile administration screen, theme-install.php controls the theme installation panel, and plugin-install.php does the same for the plugin installation panel.

As for other important folders inside wp-admin, then images filled with images that are used in the WordPress admin panel, css and js are "homes" for CSS code and JavaScript scripts, and network includes PHP files required for WordPress multisite functionality

This is probably where you spend most of your time working with WordPress, as it contains the most used files and features, namely themes and plugins:

Each plugin you download has its own folder in this shared folder, as seen in the example above. The content of each folder of course varies from plugin to plugin. For example, here is what the folder of the popular Akismet plugin looks like.

If you have any, then you should use FTP access to disable extensions. This can be done by deleting or simply temporarily renaming the folder with the conflicting plugin.

Just like with plugins, each theme has its own subfolders. If we open the folder with any theme, we will see there are many PHP files that all together create appearance and the structure of your theme. Let's take famous theme Divi by Elegant Themes as an example, in the main folder of which we will find the files , a functions.php, a sidebar.php, And style.css, among the rest. Divi also has separate folders for the theme's css, images, and js, which is pretty standard for most quality themes. But be that as it may, some other folders are quite unique, for example, epanel And et-pagebuilder:

Another folder is wp-includes and it's pretty big. wp-includes contains all those files that are not included in the folders described earlier. Relatively speaking, it is thanks to this folder that the site works like clockwork.

The folder is so important because most of the WordPress core files are located here. A new WordPress installation contains 140 different files in the main directory and 14 different folders (at the time of writing), including certificates, fonts, js, and widgets.

But these subfolders are not as important as the files that are in the main directory, for example, functions.php. This little file is an important part of WordPress core as it contains a lot of different functions that keep WordPress running smoothly. For example, this line of code is the first thing you see when you open this file, and this function is needed to transform the data into other formats.

/** * Convert given date string into a different format. * * $format should be either a PHP date format string, e.g. "U" for a Unix * timestamp, or "G" for a Unix timestamp assuming that $date is GMT. * * If $translate is true then the given date and format string will * be passed to date_i18n() for translation. * * @since 0.71 * * @param string $format Format of the date to return. * @param string $date Date string to convert. * @param bool $translate Whether the return date should be translated. default true. * @return string|int|bool Formatted date string or Unix timestamp. False if $date is empty. */ function mysql2date($format, $date, $translate = true) ( ​​if (empty($date)) return false; if ("G" == $format) return strtotime($date . " +0000"); $i = strtotime($date); if ("U" == $format) return $i; if ($translate) return date_i18n($format, $i); else return date($format, $i); )

Other key files are cache.php(controls the process of adding and deleting data from the cache, and is also responsible for closing or restarting it), links.php (the functionality that is responsible for WordPress links) and version.php (responsible for the version of WordPress).

I really hope that this article will allow beginners to get a basic idea and knowledge about the structure of your WordPress site. Agree - not every driver needs to be an auto mechanic, but to imagine where the engine is in the car, and where the suspension is, is for everyone who is driving. Well, this is so, by the way 🙂

This post will collect information about the structure of WordPress in one way or another. The structure of the database and tables in the database - why they are and what is stored in them. The folder structure, what files are in them, the purpose of these files and directories. List of roles, functions and more.

The information was transferred from the entry "WordPress notes, tricks and hacks", which has grown so much that it needs to be split up already.

  • Administrator- absolute access to managing themes, users, plugins, settings, pages, posts, categories, comments, content export-import.
  • Editor- editing, creating, deleting your own and other people's content, moderating comments, editing categories, deleting, editing, publishing your own and other people's pages, records, uploading files.
  • Author- creating, editing, publishing and deleting only your content - records. Can't create pages. Has the rights to download images, files and any materials.
  • Contributor- can add new content - entry, without the right to publish. Can edit and delete your drafts. Cannot add images to post, only through using HTML code that will link to the image. Participants can also see the recordings in the console.
  • Subscriber- you can allow subscribers to see private posts and pages without additional plugins or code.

Table structure in wordpress database:

  • wp_commentmeta - for comment metadata
  • wp_comments - comments
  • wp_links - deprecated stores the information entered in the WordPress links section
  • wp_options - everything in the admin panel options section is stored in this table, site settings
  • wp_postmeta - post metadata
  • wp_posts - posts, pages, their revisions and navigation items
    • id - posts, pages, revisions
    • post_author - user id - author.
    • post_date - post date
    • post_date_gmt - post date in GMT
    • post_content - post content
    • post_title - post title
    • post_excerpt - post description
    • post_status – post status: publish, draft, auto-draft, inherit
    • comment_status - "open" if commenting on a post is allowed and "closed" if not.
    • ping_status
    • post_password - the password to read the post if it is password protected
    • post_name - post alias to be used in CNC links.
    • to_ping
    • pinged
    • post_modified - date of last post modification
    • post_modified_gmt - date of the last post modification in GMT
    • post_content_filtered
    • post_parent - id of the parent post entry, if there is no parent, then the value is 0
    • guid - entry URL in the form http://site/?p=id for posts or http://site/category/test/name - for pages
    • menu_order - zero for post, page order, used to determine page order
    • post_type - post type, can be: post - post, page - page, revision - saved version of page or post, attachment - media, e.g. image page
    • post_mime_type
    • comment_count - number of comments on the post
  • wp_terms - mainly contains information on terms / taxonomies (category, link category, label, menu)
    • term_id - term id (eg category)
    • name - term name
    • slug - how the term will be written in the link
  • wp_term_relationships - relationships between posts and categories, tags and other taxonomies
    • object_id - post id, links
    • term_taxonomy_id - id of the category or any other taxonomy term (category, link category, label)
    • term_order - used for sorting
  • wp_term_taxonomy - describes what type a particular term is
    • term_taxonomy_id - taxonomy id
    • term_id - term id
    • taxonomy - taxonomy type: category, link_category, post_tag, nav_menu
    • parent - parent term, if for example a category is nested within a category
    • count - the number of objects (posts, links) associated with the taxonomy
  • wp_usermeta - user rights and additional information about registered users
  • wp_users - all users

Wordpress file structure

The root directory contains the following folders and folder files:

  • wp-config.php- this php file contains the database name and password, encoding, table prefix, language, cache size, many other parameters can be added to the file.
  • .htaccess file- additional configuration file Apache web server, as well as similar servers. Allows you to set a large number of additional settings and permissions for the web server to work in separate directories.
  • wp-includes- wordpress core. The folder is overwritten with every update.
  • wp-admin- CSS, JavaScript and PHP files that provide the admin console. The folder is overwritten with every update.
  • wp-content- contains custom folders and consists of folders:
    • languages ​​- contains engine translation files in .mo and .po format
    • plugins - installed plugins
    • themes- installed templates, at least one template must be installed. May contain the following folders and files:
      • index.php - template home page site also loads the sidebar file. Required file, at the root of the template folder
      • style.css - required file, responsible for the css styles of the template, in the root of the template folder
      • header.php - the file responsible for displaying data in the section and top menu
      • sidebar.php - the file is responsible for generating side (additional) columns. Basically, headings, tags, banners are displayed here.
      • footer.php - the file is responsible for displaying the footer, bottom menu, copyrights and closes HTML tags
      • single.php - responsible for displaying individual posts.
      • page.php - responsible for displaying individual pages (for example, "Contacts", "About Us", etc.)
      • archive.php - responsible for displaying the post archive page
      • category.php - generates a page that displays posts by category
      • tag.php - page template that displays a list of publications by tags
      • comments.php - the file describes the display of comments
      • functions.php additional file with PHP code, thanks to which you can enable or disable, add or remove certain functionality. Custom code is often added to this file if something needs to be improved.
      • /css/ - this folder may contain additional css files
      • /js/ - folder with JavaScript files
      • /images/ - folder contains images embedded in the template
      • /languages/ - folder contains theme translation files
    • uploads - media files: images, music, documents, etc.

Template Tags in WordPress

Template tags are PHP functions in WordPress for displaying information or for setting up a blog, for example wp_list_pages() - displays a list of pages as links.

In wordpress itself, template tags are described in the following files:

  • wp-includes/author-template.php - template tags associated with the author
  • wp-includes/bookmark-template.php - template tags related to bookmarks
  • wp-includes/category-template.php - template tags about all conditions and taxonomy, including categories and tags
  • wp-includes/comment-template.php - file for comment section template tags
  • wp-includes/link-template.php - template tags for links (permalinks, attachment links, archive links, etc.)
  • wp-includes/nav-menu-template.php - template tags for the navigation menu
  • wp-includes/post-template.php - template tags associated with posts
  • wp-includes/post-thumbnail-template.php - file for template tags related to post thumbnails
  • wp-includes/general-template.php - file for other template tags that can be used anywhere
Liked the article? Share with friends!
Was this article helpful?
Yes
Not
Thanks for your feedback!
Something went wrong and your vote was not counted.
Thanks. Your message has been sent
Did you find an error in the text?
Select it, click Ctrl+Enter and we'll fix it!