[ad_1]

While it’s entirely possible to interact with your WordPress website only through the dashboard, understanding how your install is structured, and which files perform which functions, is crucial in order to attain a higher degree of control over your site. At the very least, this understanding will enable you to troubleshoot any errors that might arise much more easily.

Each WordPress install starts out with the same directory structure and core files. Every plugin or theme you install, every script you add, and every error screen that appears, is possible thanks to the CMS’s backbone. While the idea of poking around these files may seem intimidating at first, it’s much simpler than it looks.

Over the course of this article, we’ll review the contents of the most important WordPress folders, paying special attention to the core files that power your site.

Introducing the WordPress Directory Structure

The WordPress file structure is honestly pretty simple at the higher levels. You have your public_html folder, where its three key folders are located, as well as a lot of important files such as wp-config.php and .htaccess. Even if it’s your first time poking around in the back of your WordPress installation, chances are that you’ve already familiar with those names.

In order to access these files and folders, you must use either your hosting service’s cPanel file manager, or a File Transfer Protocol (FTP) client. For the purposes of this guide, we’ll be using FileZilla. Regardless of your choice, this is what the inside of your public_html folder should look like:

Screenshot of the public_html folder as seen from an FTP manager.
  • https://www.facebook.com/lafactoryworld
  • https://twitter.com/lafactory
  • Gmail
  • https://www.linkedin.com/company/lafactory-inc

Before we jump into those three top level folders, let’s take a look at some of the files laying around inside public_html. First of all, we have .htaccess (short for “hypertext access”). This enables you to control permalink structure, files, folders, and access to them across your WordPress installation. A pristine .htaccess file should look as follows:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Then we’ve got index.php, which will be returned as your homepage by default unless it’s superseded by either a front-page.php or a home.php file:

Screenshot of index.php as seen from an FTP manager.
  • https://www.facebook.com/lafactoryworld
  • https://twitter.com/lafactory
  • Gmail
  • https://www.linkedin.com/company/lafactory-inc

Another crucial file in this directory is wp-config.php. This handles WordPress’ base configuration, and includes your MySQL settings, secret keys, and database table prefix. 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', 'notarealname');
/** MySQL database username */
define('DB_USER', 'notarealuser');
/** MySQL database password */
define('DB_PASSWORD', 'notarealpassword');
/** MySQL hostname */
define('DB_HOST', 'localhost');

Other notable files on this directory include wp-activate.php, wp-signup.php, and wp-signup.php, which together handle the signup, login, and user confirmation process. We’ve also got wp-comments-post.php (which handles the commenting function and prevents comment duplicates), and wp-settings.php, which sets up some common WordPress variables.

Having covered those, let’s move onto the first of the top level folders, wp-admin.

The wp-admin Folder

Screenshot of the wp-admin folder as seen from an FTP manager.
  • https://www.facebook.com/lafactoryworld
  • https://twitter.com/lafactory
  • Gmail
  • https://www.linkedin.com/company/lafactory-inc

As its name implies, this is the folder that houses the files powering your admin tools as a WordPress user. For example, admin.php (which is at the heart of the folder), enables connection to the database, displays the WordPress dashboard, and performs any other number of key functions, such as checking whether any given user is in fact the admin in question. If they are, the script proceeds to call upon the wp-load.php file, which in turn loads the wp-config.php file:

/**

* 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 the files in this folder, you’ll find that most of them correspond to the functions you’ve come to know on the WordPress dashboard. For example, profile.php powers the user profile administration screen, while theme-install.php controls the theme installation panel, and plugin-install.php does the same for the plugins panel.

As for the other important folders inside of wp-admin, images is filled with images used in the WordPress administration panel, css and js are devoted to CSS code and JavaScript scripts respectively, and network houses the PHP files necessary to power WordPress multisite.

The wp-content Folder

This is the section of the back end where you’re likely to spend most of your time during the course of your relationship with WordPress. Its two most popular functions are located inside – of course, we’re talking about themes and plugins:

A screenshot of the wp-content folder as seen from an FTP manager.
  • https://www.facebook.com/lafactoryworld
  • https://twitter.com/lafactory
  • Gmail
  • https://www.linkedin.com/company/lafactory-inc

The plugins Folder

A screenshot of the plugins folder as seen from an FTP manager.
  • https://www.facebook.com/lafactoryworld
  • https://twitter.com/lafactory
  • Gmail
  • https://www.linkedin.com/company/lafactory-inc

Each plugin you upload to WordPress will have its own subfolder within the plugins folder, as seen in the example above. The contents of each of these vary from plugin to plugin. Here, for example, is a quick look inside the Akismet plugin’s folder:

A screenshot of the Akistmet plugin folder as seen from an FTP manager.
  • https://www.facebook.com/lafactoryworld
  • https://twitter.com/lafactory
  • Gmail
  • https://www.linkedin.com/company/lafactory-inc

As we’ve mentioned in multiple troubleshooting articles such as Getting the 403 Forbidden Error in WordPress, Here’s How to Fix It and How to Fix the 500 Internal Server Error on Your WordPress Website, disabling plugins via FTP can be a necessary step to solve compatibility issues.

The themes Folder

A screenshot of the themes folder as seen from an FTP manager.
  • https://www.facebook.com/lafactoryworld
  • https://twitter.com/lafactory
  • Gmail
  • https://www.linkedin.com/company/lafactory-inc

As with plugins, each theme you install on your WordPress site gets its own corresponding folder on the back end, which you’ve probably already seen unless you’ve been uploading every theme through the dashboard rather than using FTP.

The first thing you’re likely to see as you access any given theme’s folder is a bunch of PHP files, which together make up its building blocks. Using Divi as an example, in its main folder you’ll find a 404.php, a functions.php, a sidebar.php, and a style.css file, among many others. Divi also includes separate folders for its css, images, and js – which are pretty much standard across most themes. However, a couple of the other folders are quite clearly unique to the theme, such as epanel and et-pagebuilder – whose names you’ll recognize if you’ve had the chance to tinker around with Divi before:

A screenshot of the Divi theme as seen from an FTP manager.
  • https://www.facebook.com/lafactoryworld
  • https://twitter.com/lafactory
  • Gmail
  • https://www.linkedin.com/company/lafactory-inc

The wp-includes Folder

A screenshot of the wp-includes folder as seen from an FTP file manager.
  • https://www.facebook.com/lafactoryworld
  • https://twitter.com/lafactory
  • Gmail
  • https://www.linkedin.com/company/lafactory-inc

The final top level folder in the WordPress directory is wp-includes, and it’s a big one. Where wp-admin includes all the files necessary to power said admin functions, and wp-content stores all your themes and plugins, wp-includes is what makes the rest of your site run like clockwork.

This folder is, in fact, so crucial that it’s where most of the WordPress core files are stored. Right off the bat, a fresh WordPress install will include over 140 different files in the main directory, and 14 different folders (at the time of this writing) including certificates, fonts, js, theme-compat, and widgets.

These subfolders, however, aren’t quite as important as the files included in the main folder, such as functions.php. This little file is considered to be part of WordPress’ core, and it’s jam packed with a lot of the little functions that enable your WordPress installation to work. As an example, these lines of code are the first things you’ll see if you open the file on a text editor, and they’re just a regular function meant to transform dates into different 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 include cache.php (which handles the processes of adding and removing data from the cache, as well as closing or resetting it), links.php (which includes functions that power WordPress’ links feature), and version.php (which states your version of WordPress).

Conclusion

Although delving into the back end of your WordPress install is understandably scary, with a little practice and a bit of poking around, you’ll soon come to know the ins and outs of its directories and core files by heart. This knowledge will no doubt come in quite handy in the future, whether you need to troubleshoot an error, implement a simple tweak, or simply astound your dinner guests with your encyclopedic knowledge of WordPress trivia (and only one of these applications is not true!).

Every journey begins with a few short steps, however, and in your case those are:

  1. Get acquainted with the WordPress directory structure, especially the wp-admin, wp-content, and wp-includes folders.
  2. Familiarize yourself with the WordPress core files, including wp-config.php, functions.php, and .htaccess.

Have you ever unwittingly broken your WordPress installation by poking around its back end? Don’t worry, we’ve all been there. Subscribe and share your experiences with us in the comments section below!

Article thumbnail image by Rashad Ashurov / shutterstock.com

[ad_2]

Source link