Tips for Advanced WordPress Users

Tips for Advanced WordPress Users
We have talked on several occasions that WordPress can be modified through code, as a general rule, the wp-config.php file.

This file can be found in the root folder of our WordPress installation, we can also find other important configuration files.

This post is aimed at advanced users because we are going to modify or add code to important files, and an error can damage our website.

However, novice users can practice using a localhost installation.

Debugging In WordPress

We have the possibility to carry out a debugging that by default in WordPress is disabled. If we have a problem on our website we can activate this debugging as it can be of great help.

We just have to add this line in the wp-config.php file

define( 'WP_DEBUG', true );

A very interesting option is to be able to debug our website, without showing it on the screen but by saving the results in a file.

This file called debug.log will be created within the wp-content folder of our WordPress installation and it will store all debugging errors and warnings within the log file.

To perform this option we are going to add these lines in the wp-config.php file

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Increase Memory Limit

One of the most common errors that we can find is that our PHP memory has run out.

We can increase this memory limit by adding the following code in our wp-config.php file.

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

Change The Address Of Our Site In WordPress

This may surprise us, since there is a very simple way to do it through the Dashboard of our WordPress, Settings → General.

But maybe we cannot access our installation due to some error, or that we have already moved our site.

In this case we just have to add these lines of code in our wp-config.php file.

define('WP_HOME', 'http://www.site-address.com');
define('WP_SITEURL', 'http://www.site-address.com');

File Permissions

To perform this action we can use programs such as filezilla, but we also have the ability to do it through code.

To change the permissions we just have to add the following lines to our wp-config.php file.

define('FS_CHMOD_FILE', 0644);
define('FS_CHMOD_DIR', 0755);

Read 4 – Allowed to read files
Write 2 – Allowed to write/modify files
eXecute1 – Read/write/delete/modify/directory

7 5  5
 user  group  world
 r+w+x  r+x  r+x
 4+2+1  4+0+1  4+0+1  755

 

Multi-Site

WordPress offers us in the installation, if we do it through cPanel, the possibility of choosing to create a multisite.

If we are going to install our WordPress without using a cPanel, once the installation is finished, we can turn our WordPress into a multisite.

We just have to add the following line of code in our wp-config.php file.

define('WP_ALLOW_MULTISITE', true);

 

Post Revision Settings

We can disable or change the configuration of a useful WordPress function, which is the one that allows us to undo the changes in publications and pages by returning to a previous version or an automatic save.

We choose between different revision configurations by adding a line in our wp-config.php file.

define('AUTOSAVE_INTERVAL', 60); // 60 seconds

We will limit the number of reviews per post by adding the following line of code.

define('WP_POST_REVISIONS', 10);

We can also disable the post review function completely, although we do not recommend it, by adding this line of code.

define( 'WP_POST_REVISIONS', false );

WordPress Trash Settings

A very interesting option that WordPrees offers us is the recycle bin function called Trash.

When we trash a post, sometimes we do so, it is stored for 30 days as trash.
After this time it is automatically deleted.

To modify this behavior, we can change the number of days it will be kept in the trash by adding this line of code in the wp-config.php file.

define( 'EMPTY_TRASH_DAYS', 10 ); // 10 days

One thing we can do but do not recommend at all is to disable this feature.

We don’t recommend it because WordPress will delete our post permanently without even asking us.

If for any reason we want to recover this publication, we will not be able to do so.

You just have to add this line of code in our file by setting the number of days to 0.

define( 'EMPTY_TRASH_DAYS', 0 ); // 0 days

As we have just seen, WordPress offers us the possibility of customizing many options that by default we could not do if it were not through code.

If you have not created your website yet, you may be interested Create Your Website With WordPress.

References:
wpbeginner.com

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Shares
Share This