Help center topics

The wp-config.php file in a WordPress installation is a configuration file that contains settings and constants, rather than commands. Additional examples of commands and constants that can be added to your wp-config.php file to customize your WordPress site’s behavior:

Disable plugin and theme updates and installations:

define( 'DISALLOW_FILE_MODS', true );

Enable WordPress multisite:

define( 'WP_ALLOW_MULTISITE', true );

Increase the memory limit:

define( 'WP_MEMORY_LIMIT', '256M' );

Set the maximum file upload size:

@ini_set( 'upload_max_size', '64M' );

Disable the WordPress auto-updates:

define( 'WP_AUTO_UPDATE_CORE', false );

Enable automatic updates for minor versions:

define( 'WP_AUTO_UPDATE_CORE', 'minor' );

Enable automatic updates for all versions:

define( 'WP_AUTO_UPDATE_CORE', true );

Enable WordPress maintenance mode:

function wp_maintenance_mode() {
    if (!current_user_can('edit_themes') || !is_user_logged_in()) {
        wp_die('Maintenance, please come back soon.', 'Maintenance - please come back soon.', array('response' => '503'));
    }
}
add_action('get_header', 'wp_maintenance_mode');

Change the autosave interval:

define( 'AUTOSAVE_INTERVAL', 120 ); // Autosave every 120 seconds

Disable post revisions:

define( 'WP_POST_REVISIONS', false );

Change default theme:

define( 'WP_DEFAULT_THEME', 'your-default-theme' );
require_once(ABSPATH . 'wp-settings.php');

Force SSL for the WordPress admin area:

define( 'FORCE_SSL_ADMIN', true );

Set the default time zone:

date_default_timezone_set( 'America/New_York' );

Change the file permissions for uploaded files:

phpCopy codedefine( 'FS_CHMOD_FILE', 0644 );

Change the directory permissions for uploaded files:

phpCopy codedefine( 'FS_CHMOD_DIR', 0755 );

Disable the WordPress REST API:

phpCopy codeadd_filter( 'rest_authentication_errors', function( $result ) {
    if ( ! empty( $result ) ) {
        return $result;
    }
    if ( ! is_user_logged_in() ) {
        return new WP_Error( 'rest_not_logged_in', 'You are not currently logged in.', array( 'status' => 401 ) );
    }
    return $result;
});

As mentioned earlier, when adding these commands to your wp-config.php file, ensure they are placed before the line:

/* That's all, stop editing! Happy publishing. */.

Always make a backup of your wp-config.php file before making any changes. This will allow you to quickly restore the original file if something goes wrong.

Join the conversation

Table of Contents

UP

Free estimation in 1 day!

Protecting your privacy is important to us, so if you would like to know more regarding how we process your personal data, please check our detailed Privacy Policy.

Contact us so we can get to know your project better. The quote is free of charge.
Piotr Trąbski - CEO