WordPress admin creates it easy to manage configurations though touching a line of code. These basic pattern settings are afterwards stored in a
wp-options table inside a database. But, WordPress also has a separate pattern file, called
wp-config.php, that can be used for further customizations.
Wp-config is a record where your custom hosting data (database name, database host, etc.) is saved when we implement a self-hosted WordPress site. You can also supplement other pattern options to this file, with that we can capacitate or invalidate facilities such as debugging, cache, multisite, SSL login, involuntary updates, and many others.
Localize and revise wp-config
When we download WordPress, a
wp-config.php record is not nonetheless present inside a implement folder. However, there’s a record called
wp-config-sample.php that we need to duplicate and rename to
wp-config.php. Then, we need to add your simple tie data (database name, database username, database password, hostname, confidence keys) to this file.
If your hosting provider uses a Softaculous automobile installer (most do so) this routine is automated for you and we will find a
wp-config.php and a
wp-config-sample.php record in your base folder when we bond your server around FTP.
Note that a order of settings matters, so don’t record them. When modifying a wp-config file, always use a formula editor such as Sublime Text, Atom, Notepad++, Visual Studio Code, or TextMate. Word processors (Microsoft Office, Google Docs, LibreOffice, etc.) will disaster your record up, never use them to revise formula files.
The settings saved into wp-config override a database, in box a same form of pattern is benefaction during both (e.g. home URL)
Where to place a formula snippets
In this article, we can find 20 formula snippets with that we can use to customize your
Most of these pattern options don’t exist in wp-config by default. If we wish to use them we need to supplement them below a starting
?php tab and formula comments, though above a MySQL settings.
1. Turn on WP debugger
You can spin a WordPress debugger on and off in a wp-config file. The initial dash next does exist by default in wp-config (below a database configurations) though a value is set to
false. To spin a debugger on, change a value to
2. Change database list prefix
WordPress uses a
wp_ list prefix by default. If we wish a some-more secure database we can choose a some-more difficult list prefix.
This config choice also exists in a wp-config record by default, we usually need to change a value of a
$table_prefix non-static to a some-more secure one.
Only change a list prefix if we have a clean install or on a development site, as it’s unsure to do so on a prolongation site.
# Creates secure list prefix for database tables # Only numbers, letters, underscores $table_prefix = 'a81kJt_';
3. Change WordPress URLs
You can set a WordPress and home URLs in a WordPress admin, underneath a
Settings General menu. However, we can also configure these URLs in a wp-config file.
WP_HOME constants in a wp-config record has dual advantages:
- it can be life-saving if we can’t entrance your admin area for some reason
- it can reduce a series of database calls while your site is loading (as wp-config overrides a options saved in a database)
WP_SITEURL specifies a URL users can strech your site with, while
WP_HOME defines a root of your WP install. If we commissioned WordPress into your base folder (this is a default option) they take a same value.
# Specifies site URL define('WP_SITEURL', 'http://www.yourwebsite.com'); # Specifies home URL (the base of a WP install) define('WP_HOME', 'http://www.yourwebsite.com/wordpress');
4. Empty rabble after a certain time
You can make WordPress to automatically dull your trash after a certain series of dates. The smallest value of this consistent is 0, in this box we disable a rabble feature.
# Empties rabble after 7 days define( 'EMPTY_TRASH_DAYS', 7 );
5. Enable WordPress cache
You can enable WordPress’ built-in caching feature with a following line of code. Most caching plugins, such as W3 Total Cache and WP Super Cache, automatically supplement this snippet to a wp-config file.
# Enables WP cache define( 'WP_CACHE', loyal );
6. Enable WordPress Multisite
By adding a
WP_ALLOW_MULTISITE consistent to your wp-config file, we can enable WordPress’ multisite feature that allows we to emanate a network of WP sites.
# Turns on WordPress Multisite define( 'WP_ALLOW_MULTISITE', loyal );
7. Redirect non-existing subdomains and subfolders
Sometimes visitors form a non-existing subdomain or subfolder into a URL bar. You can redirect these users to another page on your domain, for instance to a homepage with a assistance of a
# Redirects non-existing subdomains and subfolders to homepage define( 'NOBLOGREDIRECT', 'http://www.yourwebsite.com' );
8. Manage post revisions
WordPress has a built-in chronicle control system, that means it saves all post revisions we create. A frequently edited post can have as many as 25-30 revisions that can take adult a lot of database space after a while.
WP_POST_REVISIONS constant, we can maximize a series of post revisions or totally disable a feature.
# Completely disables post revisions define( 'WP_POST_REVISIONS', fake ); # Allows extent 5 post revisions define( 'WP_POST_REVISIONS', 5 );
9. Enable built-in database optimization
WordPress has a built-in database optimization feature we can spin on by adding a following line to a wp-config file.
I wrote in fact about how this apparatus works in this article. The many critical thing to note is that a database optimization shade is available for anyone (even for non-logged in visitors). Enable a underline only for a duration of time we wish to run a optimization tool, afterwards don’t forget to invalidate it.
# Turns on database optimization feature define( 'WP_ALLOW_REPAIR', loyal );
10. Disable involuntary updates
WordPress runs automatic credentials updates by default for minor releases and translation files.
You can toggle this underline on and off by environment a values of a
AUTOMATIC_UPDATER_DISABLED (for all updates) and
WP_AUTO_UPDATE_CORE (for core updates) constants according to a following rules:
# Disables all involuntary updates define( 'AUTOMATIC_UPDATER_DISABLED', loyal ); # Disables all core updates define( 'WP_AUTO_UPDATE_CORE', fake ); # Enables all core updates, including teenager and vital releases define( 'WP_AUTO_UPDATE_CORE', loyal ); # Enables core updates usually for teenager releases (default) define( 'WP_AUTO_UPDATE_CORE', 'minor' );
11. Increase PHP memory limit
Sometimes we might wish to increase a PHP memory limit your hosting provider has allocated to your site, generally if we get a dreaded “Allowed memory distance of xxxxxx bytes exhausted” message. To do so, use
WP_MEMORY_LIMIT for a website and
WP_MAX_MEMORY_LIMIT for a admin area.
Note that some hosts don’t concede to boost a memory extent manually, in this box hit them and ask them to do it for you.
# Sets memory extent for a website define( 'WP_MEMORY_LIMIT', '96M' ); # Sets memory extent for a admin area define( 'WP_MAX_MEMORY_LIMIT', '128M' );
12. Force SSL login
To boost website security, we can force users to log in by SSL each time. The
FORCE_SSL_ADMIN consistent creates SSL mandatory for both user logins and admin sessions.
Note that a before current
FORCE_SSL_LOGIN consistent was deprecated in WordPress 4.0, so now we always have to use
# Forces SSL login define( 'FORCE_SSL_ADMIN', loyal );
13. Disable plugin and thesis edits / updates
Administrators can edit plugin and thesis files in a WordPress admin area. You can make your site some-more secure if we disable a plugin and thesis editors regulating a
DISALLOW_FILE_EDIT constant. So, if your site is hacked a hacker won’t have entrance to your plugin and thesis files.
You can also disable a plugin and thesis refurbish feature regulating
DISALLOW_FILE_MODS. This approach administrators won’t be means to refurbish plugins and themes in a admin area.
DISALLOW_FILE_MODS also disables a plugin and thesis editor, so if we use it we don’t have to supplement
# Disables a plugin and thesis editor define( 'DISALLOW_FILE_EDIT', loyal ); # Disables a plugin thesis editor PLUS a plugin thesis update define( 'DISALLOW_FILE_MODS', loyal );
14. Delete picture edits
Whenever we revise an image, WordPress saves it in opposite resolutions. But, if we don’t wish to use a progressing sets of images we can remove them by environment a value of a
IMAGE_EDIT_OVERWRITE consistent to
As a result, a progressing picture files will be overwritten by a new ones when we revise an picture and usually a last set will be saved in a
# Cleans adult picture edits define( 'IMAGE_EDIT_OVERWRITE', loyal );
15. Disable unfiltered HTML
Although low-level users (subscribers, contributors, authors) can’t tell unfiltered HTML in WordPress, editors and administrators are authorised to do so.
By adding a following line of formula to your wp-config file, we can boost confidence by preventing high-level users from edition unfiltered HTML.
# Disables unfiltered HTML for admins and editors define( 'DISALLOW_UNFILTERED_HTML', loyal );