How to Get Information to Fix Bug in WordPress
Last Updated: August 8, 2020 in Guides
Managing a WordPress site so that it can deliver the best value for company business is not a simple duty. There is a wide range of skills and knowledge required to operate WordPress sites effectively. A capacity for investigating and fixing bugs for WordPress sites is the most important to make your website run smoothly.
The process of identifying the root causes of a WordPress site may vary from site to site. It is because of the diversity in site architecture & its corresponding components. The below post provides several essential points for fixing WordPress bugs from a bird-eyes view. Therefore, troubleshooting WordPress issues should not only belong to science but also belong to art.
Understanding the Essential Architecture of a WordPress Site
Looking at DevSecOps scope, the WordPress bugs may originate from:
- Front-ends.
- Web platform – WordPress.
- Web Servers (LAMP stack).
- Operating System
- Hardware infrastructure / VPS (Amazon, VMware ESXI…).
- Network & Security.
Front-ends
Clearing cache & flushing DNS are common action plans for end-users when encountering web loading issues.
Using developer tools from clients’ web browsers to identify the problematic HTML elements, then double-check from server sites. This is often to the next level – troubleshooting at the web platform level.
Web Platform - WordPress
Notice important files and directories from WordPress home (The default value of $WP_HOME
is /var/www/html/<wordpress_root_dir>
).
File path | Descriptions |
$WP_HOME/wp-config.php |
- A configuration file for a site. |
$WP_HOME/wp-content |
- Contains contents of WordPress sites. |
$WP_HOME/wp-content/uploads |
- A directory that contains upload files of WordPress.
- This upload directory is CONFIGURABLE. |
Backup Your Current States
For complicated bugs, false-attempts in troubleshooting plans seem unavoidable. Backing up the whole system or important components is necessary to deal with unexpected outcomes while fixing bugs at WordPress sites. The backup versions can be a WordPress theme, web sources with its accompanying database. It would be ideal if developers can implement a backup of the whole host.
It would be great if system admins prepared several stable versions in advance to reduce downtime of production sites.
Clear WordPress Cache
Clearing cached data makes WordPress sites work with the latest available resource. Operators can use plugins to remove cached items for simplicity.
Troubleshooting at Pages/Posts Level
First of all, attempt several pages/posts to verify whether all pages/posts encounter similar bugs. Sometimes re-creating the page/post with similar contents resolves an issue.
Troubleshoot Plugins Level
1. Disable all plugins.
2. Re-activate plugins one at a time.
3. Test your site after each reactivation. Has the problem returned? If so, you have now found the suspect plugin. If not, continue to the next plugins.
4. Disable the problematic plugins, update to the latest version, find alternate plugins if it is possible.
5. Test other plugins to ensure you don’t have multiple plugin problems.
Troubleshoot themes level
1. Disable the current theme.
2. Activate a default theme or another theme.
3. If the problem has gone, the theme is causing issues. If not, move down to the WordPress core layer.
4. Re-activate all of the plugins individually to make sure there is not a composite problem. If the problem doesn’t recur, the root causes belong to the theme area.
Troubleshooting at WordPress Core
1. Download a clean version of WordPress from wordpress.org.
2. Connect to your site via SSH, FTP, or using appropriate terminals tools.
3. Rename wp-admin
and wp-includes
to ensure uploading clean copies of these directories.
4. Back up wp-config.php
just in case. These files hold your database connection details (amongst other things).
5. Upload your clean version of WordPress.
6. Test. If the issue disappears, the root cause is at the WordPress core. If the issue persists, time to proceed with further action plans.
7. Re-activate your theme and test it.
8. Re-activate your plugins and test them.
Web Server (LAMP Stack)
Web servers are software that are responsible for receiving HTTP requests, proceeding HTTP requests, and providing HTTP responses to clients. Every WordPress site runs on top of specific web servers. LAMP stack (Linux – Apache – MySql/MariaDB – PHP) is a common web server for WordPress sites.
Apache
Important directories (default values when deploying Apache on CentOS. The default values can diversify depends on different platforms).
File path | Descriptions |
/var/www/html | Webroot home directory
[root@centos-wp-01 wpadmin]# cat /etc/httpd/conf/httpd.conf | grep 'DocumentRoot' # DocumentRoot: The directory out of which you will serve your DocumentRoot "/var/www/html" |
/etc/httpd/ | The root directory of Apache Web Server
[root@centos-wp-01 wpadmin]# cat /etc/httpd/conf/httpd.conf | grep 'ServerRoot' ServerRoot "/etc/httpd" |
/etc/httpd/conf.d/ | Directory of Apache configuration |
/etc/httpd/logs | Apache logs
[root@centos-wp-01 logs]# ls -1 /etc/httpd/logs access_log access_log-20200227 access_log-20200301 access_log-20200429 error_log error_log-20200227 error_log-20200301 error_log-20200429 error_log-20200605 |
- Important configuration files: /etc/httpd/conf/httpd.conf
- List of Apache configuration files:
- [root@centos-wp-01 logs]# ls -1 /etc/httpd/conf.d/
- autoindex.conf
- php.conf
- phpMyAdmin.conf
- README
- userdir.conf
- welcome.conf
Normally, if there is any issue, it will appear in Apache logs. However, you should also check other sections.
MySQL/MariaDB
You should check the data's name in the database such as username, password, ...
PHP
One important technique of controlling PHP operation is enabling logs. WordPress operators can enable logs by modifying the .htaccess
file or the php.ini
file. When a bug occurs, developers can backup, enable debug logs, and reproduce the issue. System behaviors will be recorded in the log files. This information is useful for operators to identify the root causes and come up with resolutions.
To determine the absolute path of the log file, operators can check the parameter $_SERVER['DOCUMENT_ROOT']
.
Operating System and the Hardware Infrastructure / VPS
Monitoring the system performance with important parameters such as RAM, disk spaces, CPU usages, network traffics. The detailed utilities depend on the platform hosting WordPress sites. Nevertheless, you should double-check these parameters to troubleshoot the issues.
Network and Security
Ensure the traffic for HTTP/HTTPS protocols are under normal operation. By default, they should be on port 80/443 (HTTP/HTTPS). Another important port that should be concerned is 3306 for MySQL/Maria DB.
Be noticed that those above port numbers are common values for outgoing traffic. The internal traffics of HTTP requests & Database traffic may run on different ports.
Ask for Community Support
Because WordPress has the largest community all over the world, you can easily ask for help by providing your issues with accompanied operational logs/screenshots. There are a bunch of WordPress developers available to report bugs.
Another option is hiring freelancers to handle your WordPress bugs.
Restore the Whole System to Previous Stable Versions
In many circumstances, it is recommended to consider investigating a bug and minimize the downtime of a WordPress site. For several complicated bugs, it may take several hours to several days to resolve. Therefore, it is mandatory to have alternate actions to keep production sites under casual operation.
Last Words
The ultimate goal of fixing WordPress bugs is to deliver the best performance of websites. Therefore, it is about delivering the best value for companies’ business. Knowing how to fix WordPress bugs is an important skill to have an in-depth understanding of website operations. Operators not only maintain business operations seamlessly but also have more chances to advance their careers in the web development market.
We hope that after reading this post, you’ll have a deeper insight into bug-fixing and can get information to fix bugs yourself more easily.