Sites created on the WordPress engine have a special structure that differs from the structure

At the initial acquaintance with site building, they usually talk about the hierarchical structure of the site. Its essence lies in the fact that the entire site consists of many pages, the pages are combined into sections, which, in turn, into larger sections, etc. This system of placing materials corresponds to the system of multilevel menu. Such a site structure is similar to the file structure of a computer, therefore, it is familiar and understandable.

The structure of posting materials on the WordPress engine used to create the majority is not hierarchical, but network, therefore, at first glance, it is incomprehensible. This can, to some extent, discourage a novice webmaster from using a WordPress CMS.

That is why it becomes necessary to understand how a WordPress site works.

By the way, if you want to learn how to make websites and blogs using CMS WordPress, and with a unique design, you would be best off using the course "A unique site from scratch." You can get acquainted with him at the link below.

Unique website from scratch

There are three main directions in the structure of any site:

  1. External structure. It shows us the appearance of the page, the placement of individual elements, blocks relative to each other.
  2. Internal structure, that is, the structure of the links between the individual materials that make up the content.
  3. A file structure showing the relationship of the files that make up the entire site.

So what is the look and feel of a WordPress site?

It should be noted right away that it depends on the choice of the template. There are a huge number of such templates and, of course, sites can be very different from each other. But there are also common features that we will pay attention to. This site can be considered as an example.

At the top of the page there is usually header... It may contain the name of the site, logo, slogan, sometimes a search bar, social media buttons.

Under the header, and sometimes under it, there is most often the main menu.

At the bottom of the page, we see footer... It can contain service information. For example, about the authors of the site, copyright. Sometimes there you can find social media buttons, some navigation elements, etc.

In the middle of the page there is a feed of records and side column (sidebar).

Posts (post)- the main part of a WordPress site. It is in them that the main content is located, what the creator of the site wanted to tell his visitors.

Each new recording appears at the top of the tape, the old ones go down below. Only a limited number of records can be seen on a page, for example, ten. The rest of the entries can be navigated using the corresponding navigation buttons. Another feature of the feed is that on the main page, most often we see the entries not completely, but only the first paragraphs. This makes it faster to select the desired article. But this already refers to the internal structure of the site.

In addition to the feed of records, content is also located on permanent pages that do not change or move. Such pages usually contain information about the author, about the site, sitemap, contact information, etc.

To the side of the tape is side column (sidebar)... There may also be various options in its location. The sidebar can be located on the left or right, it can be one or two.

For example, the template Admired, used on this site, allows you to use the following options for the location of the sidebar:

The sidebar consists of separate blocks-widgets (widget)... Their number and location are determined by the site administrator and can be easily modified.

Now let's move on to the internal structure of a WordPress site. It is in it that the features of this engine lie. The navigation system consists of several parts.

First, the main menu. This menu takes us to the permanent pages. There can be many such pages, but the menu can be complex, multi-level. In this case, we have a hierarchical structure. But the menu items do not lead to records, with the exception of one item, which opens the main tape of records.

To navigate through the records, a different system is used based on the concepts of "heading" and "label".

When writing the next article, it is tied to any heading, or even not one, but two, three. The sidebar has a widget with a list of headings, and we can select from the entire feed of posts articles belonging to one heading.

In addition, each article is assigned tags - words that characterize this entry. There can also be several of these tags, and you can select records by tags. Tags are usually visible at the end of each article. In addition, a "Tag cloud" widget is often placed in the sidebar, which shows all tags and allows you to select articles by clicking on these keywords.

The external structure of the page and the structure of the site materials are important for, but the file structure is not visible to them. She is mainly of interest to the developers of the site.

Briefly about this structure. Like any site, a WordPress site consists of many files. Let's consider the most important thing.

First, all content is stored separately on the server in a MySQL database.

Secondly, image files are located in separate folders.

And thirdly, the pages themselves are formed from separate php files. The number of these files can be different, it also depends on the choice of the template, but there are basic, required files.

To see these files, you need to select Appearance? Edited R. A list of all WP files will open on the right side. For example:

  • Archives
    (archive.php)

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

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

Almost all important components that make up your site, such as themes, plugins, etc., contain exactly these three folders. At the same time, they have their own access rights, allowing the administrator to decide "who" and "what" can be done in them. By "whom" here we mean a user who will have the following associations with resources:

  • Owner - direct ownership;
  • Group - ownership by joining a group;
  • Others are lack of ownership and group.

Web server users and their groups

Before continuing to analyze 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 the rights to perform some actions on the web server. Take the FTP file transfer protocol, for example. As soon as you need to upload any image via FPT, you will use the corresponding 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, which allows you to manage the site on Wordpress, install plugins and themes, upload images through the media manager, etc. It is on his behalf that new files are created when you do these things in your admin panel.

Any single 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 differentiate between accounts. Nevertheless, there are also such hosts on which these types of users are different, although they belong to the same group. Due to the existence of different types of users, you have the ability to configure the correct access control for your site.

WordPress File Action Permissions

Any resource in WordPress is associated with a specific set of presets that dictate what the user can do with it. There are three things we can do 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. So 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, for example, 664, in which:

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

Moreover, each value of the indicated numbers determines all the capabilities that this type of user has. In the case of 664, 6 is read-only and 4 is read-only.

Catalogs

Directories, like the 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 catalog;
  • Write - create new and delete existing ones (in this case, the rights for the directory apply to everything that it contains);
  • Execute - enter directories (for example, using a command in the terminal).

Setting the correct constraints is vital because it is about security, not just WordPress functionality. Take, for example, config.php, it is desirable to set a hard limit of 600 (read-only) for it. Suppose that his rights are changed to 666, then anyone can see and change the configuration of your site, which means he can easily break it or make it vulnerable to external threats.

Change permissions on WordPress directories

Your hosting cPanel provides an interface where you can set any level of access 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 the special chmod command. It looks like this: chmod 644

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

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

Here's what you get:

  • 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 standard WordPress configuration, a particular server may be stricter than others and will not allow 600 to be set on wp-config.php. But you can give it a softer 640, or even 644 if that doesn't work.

In general, the safest thing to do is 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 attack. However, if you put everything on "read-only", then some usability problems are possible.

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

Conclusion

So, we looked at how important permissions play to access WordPress resources. If they are set correctly, then this can significantly strengthen the security measures of your site, otherwise you can get many problems, including very serious ones, both with the security and with the general performance of WordPress. Keep in mind that you can also set limits on WordPress resources via Htaccess, but that will get a little more complicated.

The default WordPress folder for storing uploaded images and other media (and not-so-media) files is wp-content / uploads /... Although this address looks normal, there are times when it needs to be changed to another, for example, in order to make pictures on a subdomain or just to have a more aesthetic and eye-pleasing address for your pictures and media files, such as: http://paperplane.su/images/... This can be easily done on both new and existing WordPress websites. But there are some differences in different versions of WordPress, in recent versions it has become a little more difficult to do (besides, the developers' changes are not entirely justified).

Change download folder in WordPress 3.5 and newer¶

In one of the latest (almost) updates, WordPress 3.5 removed the ability to enter your custom path to the downloads folder. All new WordPress blogs will by default use wp-content... The option to change it has been removed from the UI altogether to avoid confusion. But you can still set a custom download folder by adding the desired constant to the file wp-config.php:

  • Open the file wp-config.php your blog, which lies at the root of the site (using FTP access). Then you need to add a small piece of PHP code to set your download directory, but be careful, editing the file incorrectly can crash the site. Therefore, reserve this file on your computer and edit it only via FTP, and not through the interface of WordPress itself.
  • To change to your folder, for example, just images from the site root (i.e. image addresses will start with http://paperplane.su/images/) you need to add the following code:

If you want your downloads folder to be outside the wp-content directory, for example http://www.example.com/files/, then you need to set the path for downloads in wp-config.php like this:

1 define ("UPLOADS", "". "files");

Please note that the option Put the files I have uploaded to folders by month and year is still available in newer versions older than 3.5.

Change download folder in older versions of WordPress (up to 3.5) ¶

In older versions of WordPress, it is very easy to change the folder (I still don't understand why this feature was removed). In principle, there is nothing to explain, but to the heap I'll do it:

  • In the WordPress admin area, go to the menu Options -> Media files... Below you will see a section in which you need to add the folder address. In field Save files in this folder enter the name of the folder you want to use instead wp-content / uploads.
  • In the second field Full URL path to files if necessary, enter the full URL path to the new image folder along with the domain. But you need it in rare cases, for example, to organize the storage of images on a subdomain.

Remember to save your changes. And be sure to check after the changes whether they took effect by creating a test post and adding images to it. If everything went well, then your pictures will be uploaded where necessary and will be available for adding to the post.

Possible problems¶

Invalid full URL path- you need to know for sure your absolute path of the site on the server from the root of the file system. You should either know this path, or look somewhere, or ask the support of your hosting. For example, in the CPanel hosting administration panel, you can see your exact path, in others, you can also follow the idea. In most cases, it should look something like this / home / username / public_html / images.

Folder rights- incorrect setting of the rights to the selected folder will not allow adding anything to it. Make sure that the folder you have selected has 777 permissions (everyone can write to it). You can do this in the admin panel of your hosting or in the FTP client that you are using.

Hello friends. Very often when answering readers' questions, one has to face the fact that when asking questions about the various functionality of themes or plugins, many do not even imagine the basic structure of their site on the server. This is surprising, but true. In this article, we'll take a look at the basic, most important, standard WordPress folders, with a focus on the root files that your site actually runs on.

WordPress directory structure

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

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

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

Before we start looking at these top three folders, let's take a look at the files that lie inside public_html just like that. 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. This is what a standard file looks like .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 that by default represents your home page, unless of course it is overridden 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 basic WordPress configuration, including settings for the database. MySQL, secret keys, and database prefix information. This is how 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", "notarealname"); / ** MySQL database username * / define ("DB_USER", "notarealuser"); / ** MySQL database password * / define ("DB_PASSWORD", "notarealpassword"); / ** 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 toolkit is. 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 checking if a given user is an administrator. If the user is an administrator, then the use of the file 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 area. 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 Is the home for CSS and JavaScript scripts, and network includes the PHP files required for WordPress multisite functionality to work

This is probably where you spend most of your time working with WordPress, as this is where the most used files and features are collected, 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, this 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 plugins, each theme has its own subfolders. If we open a folder with any theme, we will see a lot of PHP files there, which together create the look and structure of your theme. Take the famous Divi theme 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 css, images and js themes, 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 previously described folders. Relatively speaking, it is thanks to this folder that the site works like a clock.

The folder is so important because most of the WordPress core files reside here. The new WordPress installation contains 140 different files in the main directory and 14 different folders (at the time of this 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 the WordPress core, as it contains a wide variety of functions that keep WordPress running smoothly. For example, these lines of code are the first thing that you will see if 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(manages the process of adding and removing data from the cache, and is also responsible for closing or restarting it), links.php (functionality that is responsible for WordPress links) and version.php (responsible for the WordPress version).

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

Want to know more about the WordPress file structure? And also about the core of the WordPress software, themes, plugins and all the custom uploads that are stored on the site? I'll cover all of this in this article.

Why do you need to know the WordPress file structure?

Many users start with WordPress without any knowledge of its files and directories, which is very bad. After all, knowing about WordPress files and directories, where, what and why is stored, can help solve many common problems without outside help.

In this article, you will learn:

  • What files and directories are root.
  • Where WordPress stores images and media uploads.
  • Where WordPress stores themes and plugins.
  • Where config files are stored.

Now let's get straight to examining the WordPress file structure.

Accessing WordPress files and directories

First, log into your WordPress server using your FTP client. For more details read how to use FTP to upload WordPress files (in the process of writing). A simpler alternative to FTP is File Manager (a web application with a built-in cPanel admin panel). Once you log into WordPress via FTP or File Manager, you will see the file and directory structure something like this:

The WordPress root files are highlighted in red. The correct operation of the site depends on these files, in no case do not change anything in them yourself.

Here is a list of these files and folders in the root directory:

  • wp-admin
  • wp-includes
  • wp-activate.php
  • wp-blog-header.php
  • wp-comments-post.php
  • wp-config-sample.php
  • wp-cron.php
  • wp-links-opml.php
  • wp-load.php
  • wp-login.php
  • wp-mail.php
  • wp-settings.php
  • wp-signup.php
  • wp-trackback.php

Config files

There are some special configuration files stored in the WordPress root directory. These files contain important parameters specific to your WordPress site.

  • .htaccess is a server configuration file that WordPress uses to manage permalinks and.
  • wp-config.php - Tells WordPress how to connect to the database. It also makes some important settings.
  • index.php is an index file that basically loads and initializes all WordPress files when a user requests a page.

Sometimes it becomes necessary to edit wp-config.php or .htaccess files. At the same time, be extremely careful and careful. Any minor mistake can make your site inaccessible. That is why, before changing anything here, be sure to make backup copies of these files. If you do not see the .htaccess file in the root directory, then read the instructions why the .htaccess file is not visible in the root directory (under construction).

Depending on your WordPress installation, you may or may not have the following files in your root directory:

  • robots.txt - contains all instructions for crawling search bots
  • Favicon.ico - The favicon file is sometimes generated by the hosts themselves.

In the wp-content folder, WordPress stores all downloads, plugins, and themes.

Let's take a look inside the wp-content folder to understand how it works and what you can do here.

  • themes
  • plugins
  • uploads

WordPress stores site themes in the / wp-content / themes / folder. You can edit the theme file, but this is generally not recommended. As soon as you update the version of the site theme, all your changes will be registered during this update. This is why it is recommended for customizing the main theme.

All downloaded and installed WordPress plugins are stored in the folder / wp - content / plugins /... It is not recommended to edit the plugin files, unless you yourself have created the plugin for the needs of the site.

In many WordPress instructions, you can see the codes that are inserted into the site. It is best to add them to the child theme's functions.php file or to the site-specific plugin.

WordPress stores all images and media uploads in a folder / wp - content / uploads /... By default, they are stored in folders according to the principle / year / month /... Do not forget about this folder every time you back up a site.

You can download copies of WordPress core, themes and plugins from their sources, but if you lose your download folder it will be difficult to restore it without a backup.

The wp-content directory also contains other standard folders, such as:

  • languages ​​- this folder contains all language files of non-English-language sites.
  • upgrade is a temporary folder created by WordPress when upgrading a site version.

Wp-content also stores folders that are created by plugins. For example, the screenshot above shows the gallery folder created by the plugin. Some of these folders may contain very important files. For example, the gallery folder contains all the images. Always back up these folders to avoid losing important data.

Other folders contain files that you can safely delete. For example, W3 Total Cache or WP Super Cache can store cached files in their folders.

That's all. Hope this article helped you understand the WordPress file structure.

Do not forget to subscribe to my YouTube channel, find me on VKontakte and Twitter.