30 Apr WordPress tips and tricks – What to do when it goes wrong!
So recently while working on a client website a small mistake in the functions.php file left the site locked up with a PHP error. This is quite common to happen in development. Usually we would use a development site to duplicate the existing website so we are working live, but the extra set up costs causes clients to allow work directly on the live website.
This can be quite dangerous when it goes wrong!
Common issues that can break your website are Theme updates, Plugins and Plugin updates, manually written code or even Server updates to PHP 7. All of these may not be avoidable and may require expert help.
Firstly let’s talk about how to avoid potential errors with the website. In the old days themes would rely quite a lot on WordPress core and many versions of WordPress core would change function names and calls which would break a lot of themes. Luckily this is now avoided with newer themes.
Themes are build by developers and are tested against a lot of WordPress versions but the issue with the Plugins available it cannot check that all plugins may work with your website. It is best practice to set up a development or demo website you can test your Theme, Plugins and check for updates.
Quite often clients update plugins and break features or the plugin stops working, this can be down to quite a few various things outside the developers control like API changes (Google or Instagram for example) require each user to have their own API key.
This recently happened with a Youtube video plugin that once worked without requiring an API Key from the Google Console but once the plugin was updated the video page stopped working and just showed an error. This is common with Twitter or social plugins too.
It is always worth reading the change log of plugins to check if the update is a security fix or just a cosmetic feature update. Usually most are just to add new features but may require you to do something extra like require an API or overwrite changes to the plugin or even more change how the plugin works or looks on your website!
I would always advise to update for security fixes!
If you are unsure about updating WordPress or plugins then we would advise getting in touch with us to see how we can help you.
So how can we fix some common WordPress issues.
When moving a website to a new hosting or you add a new plugin and the website stops working correctly, it is usually a conflict between the plugin and the theme or the plugin with another plugin. It’s become more rare to have such issues as developers learn the pit falls.
If your website is showing but not working or looking correct it might be a plugin causing the issue. Disable all the plugins and view the website. 9 times out of 10 it will show your website as it should be, unless your Plugin heavy and use plugins to display most of your content.
Next, turn each plugin on 1 by 1. after each activation, check the website again. Keep doing this until you find the fault. Usually you may require to re-install the plugin, delete it completely or update it to resolve the issue.
Alternatively you could look for a similar plugin to replace it.
Fixing functions.php error message.
So you might have an error like this:
Parse error: syntax error, unexpected ‘}’ in /home/public_html/wp-content/themes/themename/functions.php on line 102
To fix this you would require FTP access or a way to access your website files outside WordPress. Usually if you have an error like this then you will be locked out of the WordPress dashboard. Usually you would use the theme editor that verifies valid code before updating. In this case the functions.php file was uploaded manually and the error occurred.
Luckily we have FTP access, we can use something like Filezilla to connect directly to the website.
Using the Path above we can find the file and the exact line the error is on.
In this example a extra “}” had been added to the end of the functions.php file.
To fix this we would just delete or comment out the error like this: //}
Note: this is an example and some errors may be much more sever and may require professional help to debug functions and the code.
If you are not having functions.php issues it might be other issues in the website a great plugin to view files is WP File Manager. Search for that in “Add Plugins” and add it. It will allow direct access to your files from inside WordPress dashboard.
You can then use the same method to locate the error file and attempt to fix the error.
Error establishing database.
Quite a common issue is connecting to your database, usually this is because details for the connection has changed such as a user, password or IP address. Most website use localhost, but some use unique IP’s to connect.
Firstly check that your database connection details for your MySQL DB are correct in the wp-config.php. This file is in your root folder of the WordPress installation. 99% of the time it is one of the following issues, user name changed, password changed, permissions revoked for database user or the IP.
If you think the details are correct, then set up a new database user and assign it to your WordPress installation database and test those details. Make sure you set privileges to all.
Still having issues? Then contact us to help!
This blog is for educational purposes and would suggest strongly to contact a professional WordPress developer to undertake any website issues you have.