Understanding The WordPress Directory And File Structure – Help From wpbeginner

It really helps in backing up your website if you understand the WordPress file and directory structure and a really good introduction to the subject is the BEGINNER’S GUIDE TO WORDPRESS FILE AND DIRECTORY STRUCTURE from wpbeginner.

Where is the root directory for  WordPress?

 Gary Calhoun on Aug 11, 2015
Generally its in a folder called public_html or httpdocs, you should see folders in there wp content, wp-admin, wp-config.php if you see those then that’s the root directory

Accessing WordPress Files and Directories

First, you will need a FTP client to connect to your WordPress server. See our guide on how to use FTP to upload WordPress files for detailed instructions.
An easier alternative to FTP is File Manager. It is a web based application that comes built into cPanel dashboard of your WordPress hosting account.
Once you have connected to your WordPress site either using FTP or File Manager, you will see a file and directory structure that looks like this:

fig1

Files and folders in the red squares are the core WordPress files. These are the files and folders that run your WordPress site. You are not supposed to edit those files on your own.

WordPress Configuration Files

Your WordPress root directory contains some special configuration files. These files contain important settings specific to your WordPress site

fig2

  • .htaccess – A server configuration file, WordPress uses it to manage permalinksand redirects.
  • wp-config.php – This file tells WordPress how to connect to your database. It also sets some global settings for your WordPress site.
  • index.php – The index file basically loads and initializes all your WordPress files when a page is requested by a user.

You may need to edit wp-config.php or .htaccess file sometimes. Be extra careful when editing these two files. A slight mistake can make your site inaccessible. When editing these two files, always create backup copies on your computer before making any changes.

If you don’t see .htaccess file in your root directory, then checkout our guide on why you can’t find .htaccess file in your WordPress root directory.

Depending on how your WordPress site is setup, you may or may not have the following files in your root directory.

  • robots.txt – Contains instructions for search engines crawlers
  • Favicon.ico – A favicon file is sometimes generated by WordPress hosts

Inside wp-content Folder

WordPress stores all uploads, plugins, and themes in wp-content folder.

fig3

It is generally assumed that you can edit files and folders inside wp-content folder. However, this is not entirely true.

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

fig4

The contents of wp-content folder may differ from one WordPress site to another. But all WordPress sites usually have these:

  • [dir] themes
  • [dir] plugins
  • [dir] uploads
  • index.php

WordPress stores your theme files in /wp-content/themes/ folder. You can edit a theme file, but it is generally not recommended. As soon as you update your theme to a newer version, your changes will be overwritten during the update.

This is why it is recommended to create a child theme for WordPress theme customization.

All WordPress plugins you download and install on your site are stored in /wp-content/plugins/ folder. You are not supposed to edit plugin files directly, unless you wrote the plugin just for your own WordPress site.

In many WordPress tutorials, you will see code snippets that you can add to your WordPress site. The best way to add custom code to your WordPress site is by adding it to functions.php file of your child theme or by creating a site-specific plugin.

WordPress stores all your image and media uploads in the /wp-content/uploads/ folder. By default, uploads are organized in/year/month/ folders. Whenever you are creating a WordPress backup, you should include uploads folder.

You can download fresh copies of WordPress core, your theme, and installed plugins from their sources. But if you lose your uploads folder, then it would be very hard to restore it without a backup.

You can download fresh copies of WordPress core, your theme, and installed plugins from their sources. But if you lose your uploads folder, then it would be very hard to restore it without a backup.

This entry was posted in Ecommerce, Open Source Software, Wordpress. Bookmark the permalink.