Saturday, May 28, 2016

Happy 13th Birthday WordPress!

Today WordPress advances into its teenage years by turning 13 years old. Back in 2003, Matt Mullenweg created WordPress and it became a simple publishing tool to inspire the writer in everyone.


Since then, we've seen WordPress evolve from its baby steps as a simple, open-source blogging platform to a full-fledged development tool for robust websites.


Let us celebrate WordPress and all of its changes over time with some celebratory content below:



13 YEARS OF WORDPRESS


wordpress-1-4-compressor


Read about some key WordPress milestones in this article by Torque, and check out the GIF above to see how the WordPress interface has evolved over time.


HAPPY BIRTHDAY FROM THE WORDPRESS COMMUNITY



Members of the WordPress community sent in their birthday messages to celebrate WordPress turning 13 years old! Watch above.


13 EASY WORDPRESS HACKS


13-wordpress-hacks-final-hero


In honor of WordPress' 13th birthday, here are 13 useful WordPress hacks to help you create content faster than ever.


HAPPY BIRTHDAY FROM WP ENGINE



Thank you WordPress for all the opportunities you've provided for writers, developers, business owners, entrepreneurs, and more. We hope to continue the journey with you as you grow and mature into the dominance of open-source content management and we look forward to what will come in the next 13 years - Happy Birthday WordPress!


As WordPress matures, what changes would you like to see made? What do you look forward to the most? Leave a comment below. 


The post Happy 13th Birthday WordPress! appeared first on WP Engine.

How to Fix “Error Establishing Database Connection” for WordPress

If WordPress is throwing up a message telling you “Error establishing database connection” on an otherwise blank page, it means your database cannot be reached. And, obviously, your site it down. But you probably already figured that.


In most cases, this error appears because the credentials you entered for your database aren't correct, you made a mistake installing or migrating your site, or your database tables are corrupted. In any case, you'll be happy to know it's usually one of the simpler WordPress errors to resolve.


Read on to find out more about this error, how it happens and how to fix it. I recommend starting at the top of the list of solutions and working your way down until your site is back up.



What Is This Error and How Does It Happen?


Your site can be seen as having two main parts to it: Your files and your database. Your MySQL database stores much of the data that displays on your site such as usernames, passwords, posts, categories, tags and other content.


Your PHP files are built to request this information from your database and your database sends this information along to your files. Both sets of information are then put together so your site can be displayed when a browser asks for the page to load.


If something's wrong with your database, your PHP files can request information from your database, but when your database doesn't respond back by serving up the requested data, you're left with the error:


“Error establishing a database connection.”


Your PHP files are unable to connect to your database and there could be many reasons for it. Since this is the case, the trickiest part of fixing this error is figuring out exactly what caused it.


Beyond not being able to connect to your database, here are more specific reasons behind what may have caused this error:



  • You may have made an error installing WordPress or migrating it

  • The database may have been deleted by accident

  • You could have the wrong credentials entered

  • There's a conflict with the database prefix

  • Your file permissions could be set incorrectly

  • Your site URL may not be correct

  • You may have plugins or themes installed that are causing the issue

  • Your files or database may be corrupted

  • There could be a malfunction with your server or it's overloaded


Sometimes the error could come up after making some changes to your site that seem innocent enough until they take everything down. That's why it may be helpful to mention that testing changes before you publish them could help you avoid this situation in the future.


You can check out some of our other posts for details on how to test changes before pushing them live:



If you're reading this, chances are you are experiencing this error right now and you're keen to try the fixes below right away. Start with the first one and work your way down the list since it starts with the most common solutions and progresses to the more complex issues and fixes.


Before You Get Started: Back up and Restore!


Before you make any changes to your site to try and fix this error, it's a good idea to back up your entire site as-is just in case. It's better to have a backup of a slightly broken site than nothing at all. If things get worse, you can at least go back to where you started.


You can check out How to Manually Backup Your WordPress Website for details on how you can backup your site in this situation.


If you already have a backup of a restore point when your site was working, go ahead and restore your site.


This may not be the best solution for everyone, especially if your users have submitted a lot of content in your Multisite network that you don't want to lose. If this is the case for you or you don't have a valid backup of your site, you can try some of the other fixes below.


1. Deactivate Your Plugins


Sometimes, a plugin could make a change to your database that ends up breaking your site, such as if you have a security plugin that changes your database prefix or file permissions, for example. If your other plugins don't expect this to happen, it could cause a malfunction and your site would go down.


Also, some managed hosting plans have a strict list of plugins you aren't allowed to install and activate to ensure the security of the server you're renting from them. If you were to install and activate the prohibited plugin, it could bring down your site.


That's why deactivating your plugins can often be an effective way to troubleshoot and fix the connection error at the same time. Since you don't have access to your backend to deactivate your plugins, this is still possible by accessing your files.


After logging into cPanel, go to Files > File Manager and find the directory your site is in. Navigate to /wp-content/plugins/ and for each of the plugin folders listed, temporarily rename them.






An amendment is made to a plugin folder name.
You can rename a file or folder in cPanel.



Click on the first one on the list, then select the Rename button at the top of the page.


Keep the original name intact so you don't forget what the plugin was later on, but add something at the end such as -deactivated to remind you why you renamed it.






Click Rename File and move on to renaming the other plugins on the list in the same way. If your site comes back up, then that means one of your plugins was responsible.


Rename the plugin folders to their original names one-by-one and check if your site is available between each name change. When your site goes back down, the culprit is the last plugin you reverted to its original name.


At this point, you can look into the plugin more in-depth to find out exactly what the cause was for the error and you can also replace it with a similar plugin.


It's important to note that if one of your plugins made a major change to your database that caused your site to go down, deactivating the plugin won't fix the problem. In such a case, you would need to continue through the fixes below to resolve the issue.


2. Checking Your Credentials


Verifying Your Site's URLs


If you haven't been able to get your site back up yet, check the details you have written in your wp-config.php file and compare them to the information for your database. Fortunately, you don't need to be able to access the backend of your site.


In cPanel, you can find your wp-config.php file by going to Files > File Manager and navigating to the directory where your site is located. Click on the wp-config.php file on the list, then click Edit at the top of the page.


There are a few things you need to look for and you should also make a note of them so you can compare what you find here with what should be the same details in your database.


First, take a look through the wp-config.php file and see if you can find something similar to the example below:




You may not see these two lines because you need to add them in yourself, but if you added them previously, then you need to make note of them and make sure they're correct. If they're not, correct them right away.


To correct the URLs, substitute http://your-site.com in the example above for the correct URLs of your site. Also, be sure it's properly structured and doesn't have any typos. If you have an SSL certificate enabled on your domain, you should replace http:// with https://.


You also need to pay close attention to whether the URLs that you found have www. included. If your database includes a URL without it or vice versa, then this needs to be changed to match your database.


You can also see more details on SSL certificates by checking out one of our other posts How to Use SSL and HTTPS with WordPress.


You can also try adding these two lines with the correct URLs if they're not already there. Sometimes the database may become unavailable because the incorrect URLs were entered into the Settings > General page in the admin dashboard for single installs of WordPress or before Multisite was enabled.


If you add these lines and the error persists, you can take them out and continue trying the next fixes. You could also try a similar approach with the functions.php file found under the /wp-includes/ folder.


See if you can find similar lines to these examples below:




Just like the example above for the wp-config.php file, these lines are only in your functions.php file if you added them before. If you do see them, make sure they're correct and free of typos and if not, correct them, then see if your site goes back up.


Replace http://your-site.com for your actual URLs and if you have an SSL certificate installed, don't forget to add https:// instead of http://.


Also, check if www. is included in the URLs since if it's not included in the database but it's present in your file and vice versa, then your site would go down. Make the change to include or remove www. from the URL if necessary.


If your site comes back up or if it doesn't remove the lines above and don't leave them there. If that didn't work, continue with the other fixes.


Checking Your Database Details


Go back to your wp-config.php file and look for this block of text that you can find toward the top of the document:




Make a note of your database name, username, password and hostname. In the example above, your database name would be where you see database_name_here, your real username would replace username_here and your actual password would be found where the example displays password_here.


Chances are your hostname would be the same and would be localhost, although, it may be different for you. It's important that you contact your hosting provider and verify whether this line is correct and if localhost should be set to something else instead.


If a change needs to be made to your hostname, save it to your wp-config.php file and check if your site is up.


If your host verifies that your hostname is correct or the change you made doesn't do the trick, then make a note of all the other credentials in the example above and scroll down slightly in the document.


Also, look for a similar line to the one below to find the database prefix that your files are requesting:




You may have something different in your file than wp in the example above, but whatever the value is before the underscore, this is what should also be found in your database. Make a note of this as well.


Next, go back to the cPanel homepage and click on the MySQL Databases button under the Databases section. Scroll down to the Current Databases section and find the database for your site on the list.



Verify your database name and username in cPanel.
Verify your database name and username in cPanel.


Compare the database name and username listed here with this same information listed in your wp-config.php file. If the details don't match, change these details in your wp-config.php file so they're the same. Don't forget to save your changes.


You would change the login credentials that were previously mentioned above in the define('DB_NAME', 'database_name_here'); and define('DB_USER', 'username_here'); lines. You would change the database_name_here part for the actual database name you looked up and the username_ here portion for the correct username you found.


You can also try updating the password associated with the username for your database. On the MySQL Databases page, go to the Current Users section and click the Change Password button.



The
You can try changing the password for your database's user to fix your site.


Once you have changed the password, update your wp-config.php file to reflect the change. You would update the define('DB_PASSWORD', 'password_here'); line and in particular, the password_here part.


Check if your site is up and if not, you can verify that your database username and password is correct and that this user can successfully connect to your database.


Create a test file in the root of your site and save the following code to it to make sure there's no room for human error:




Don't forget to change your_hostname with your correct hostname, databse_username with your actual database's username and finally, replace database_password with your real password.


You can name the file anything you want, but I recommend something that's descriptive such as testdatabase.php or testdb.php. Just be sure it ends in .php or this test won't work.


Once that's done, access this file from your browser. Using the example above, you would go to http://your-site.com/testdb.php and if the login details work, you would see a “success” message on the page.


If the connection to your database is unsuccessful, then you know either your username or password isn't matching up and needs to be changed in your wp-config.php file. You can review the steps above to make the changes.






The
You can try adding a new username with a new password if all else fails.


You can also try creating a new username and password if all else fails. In cPanel, go to Databases > MySQL Databases and scroll down to the Add New User section.


Enter a new username and password and click the Create User button. Now you can add this new user to your database.











The
Add your new user to your database once you create one.



The next area on the page lets you add a the new user you created to your database. Select it from the drop down list labelled User.


Next, select your database from the list right under it. Click the Add button and your new username is added to your database.






The final step required is to update your wp-config.php file to reflect these new login details. You would do it in the same was that was previously outlined, but be sure to include the database prefix when adding it to your wp-config.php file or else it won't work.


Don't forget to save your file changes. Now, you can visit your site and see if it's back up. If it's still a no-go, you can try repairing your database.


3. Fixing Your Database


Restoring Proper Permissions


When all else fails, you can try checking your file permissions to make sure they're set correctly. If they're not set properly, it can cause the database connection error.


You can check out our post Understanding File Permissions and Using Them to Secure Your Site for details on how to properly set file permissions, although, there's an easier way to reset the permissions for your files.


You can replace all your core files with fresh ones. To do this, download the latest copy of WordPress from WordPress.org. Uncompress the folder and delete the wp-config-sample.php file and /wp-content/ folder.


Since both of these contain crucial data you need for your site to work, you don't want them replaced at all costs. Deleting these from the fresh copy eliminates accidentally overwriting them on your site.


Use your favorite FTP client to transfer the fresh copies of the WordPress core over to your site and don't forget to choose the option to overwrite all the old files with the new. That way, you won't have to worry about the added step of deleting your old files before you transfer over the new ones.


For details on using FTP, check out our post How to Use FTP Properly with WordPress.


Repairing Your Database


Repairing your database tables usually works if everything else you have tried doesn't seem to do the trick, especially if you have access to your front end or back end, but not both.


To repair your database, open your wp-config.php file in cPanel or after downloading it through FTP and add the following line to it, then save the file.




Unlike most other edits to this file, it doesn't exactly matter where you place it as long as it's not smack-dab in the middle of another line. You can place it before the “happy blogging” line like you would other additions so you don't forget about it or right at the end. Whatever works for you is fine.


Once it's saved, go to your site with the following URL structure:




Don't forget to replace your-site.com with your actual domain. When you reach the page, click the Repair Database button.



The repair database page once it has been activated.
Enable the option to repair your database to fix your site.


Once the repair has completed, immediately remove the line you added to your wp-config.php file to enable the database repair. It's not an option you want to keep enabled to ensure a hacker doesn't take advantage of it to infiltrate your site.


You can now visit your site and check whether it has come back up. If not, there's one final hail Mary pass.


4. Contact Your Host


If you have tried everything and nothing seems to work, contact your hosting provider since they may be aware of issues on your server that have nothing to do with anything you did, but still causes your site to display the connection error.


Let them know what you have already tried and even link them to this post for an easier time explaining the steps you took.


Other than that, your site should be back up and running again and the “error establishing database connection” issue should be history.


Still, it doesn't hurt to keep regular backups of your site so you can easily restore your site if something goes wrong in the future and Snapshot Pro can help you keep on top of your backups.


Have you experienced the error establishing database connection on your site? What did you do to resolve it? What are your favorite tools and tips for resolving this error? Share your experience in the comments below.


How to Add Your LinkedIn Profile to WordPress

Do you want to add your LinkedIn profile on your WordPress site? LinkedIn is a social network of professionals which helps you connect with other professionals and influencers in your industry. In this article, we will show you how to easily add LinkedIn Profile to WordPress.


How to Add Your LinkedIn Profile to WordPress


Method 1: Adding LinkedIn Profile to WordPress with Official Plugins


Just like Facebook social plugins, LinkedIn also offers several plugins that allow you to add LinkedIn features to your WordPress site.


First you need to visit the official LinkedIn Member Profile plugin page.


LinkedIn member profile plugin page


If you are not already signed in, then click on sign in with LinkedIn button.


For logged in users, it will automatically display your member profile in the preview. You can choose how you want to show your profile and show or hide connections .


LinkedIn Profile Generator Syed Balkhi


Once you are satisfied with the preview, you can click on the Get Code button. Member profile generator will show you a code snippet.


You can copy and paste this code snippet in a any post, page, or a sidebar widget on your WordPress site.


Syed Balkhi LinkedIn Profile


Method 2: Adding LinkedIn Profile to WordPress Using a Plugin


This method requires creating a LinkedIn app to use with a WordPress plugin. If the first method doesn't work for you, then you can try this one.


First thing you need to do is install and activate the WP LinkedIn plugin. For more details, see our step by step guide on how to install a WordPress plugin.


Upon activation, you need to visit Settings » LinkedIn page to configure plugin settings.


WP LinkedIn settings page


Before you can use the plugin, you need to create a LinkedIn app to get the Client ID and Client secret API keys.


You need to visit LinkedIn Developer's website and click on create application button.


Create a LinkedIn app


This will bring you to the application form for creating a new app. First you need to provide company name, a name for your application, and description.


You will also need to upload a logo for your application. You can use your blog's logo or any other image, just make sure that the image is in square shape with same width and height.


Create new app application form


After that you need to add your website address, business email, and a phone number. Check the terms box and click on the submit button.


LinkedIn will now create your app, and it will redirect you to the app Dashboard. You will find your client ID and client secret keys there.


LinkedIn API Keys


You still need to add the redirect URL to your app's settings which you can find by scrolling down a little to OAuth 2.0 section. Copy and paste the redirect URL shown on plugin's settings page and then click on the add button.


Adding redirect url in LinkedIn app


Don't forget to click on the Update button to store your app settings.


Now you can copy the client ID and Secret Keys and paste them on the plugin's settings page. After that, click on the save changes button to store your plugin settings.


WP LinkedIn comes with built-in widgets and shortcodes to add different LinkedIn features to your WordPress site.


You can go to Appearance » Widgets, and you will find LinkedIn Profile widget in the list of available widgets. Simply drag and drop it to a sidebar where you want to display your LinkedIn Profile.


LinkedIn Profile Widget


You can also display your LinkedIn profile using [li_profile] shortcode anywhere on your WordPress site.


We hope this guide helped you learn how to easily add your LinkedIn profile to WordPress. You may also want to see our list of 10 LinkedIn WordPress plugins to win new customers.


If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.


The post How to Add Your LinkedIn Profile to WordPress appeared first on WPBeginner.


The Five Most Common Restaurant Website Mistakes

I spend a lot of time thinking about what makes so many restaurant websites terrible. I've found it comes down to five simple questions a visitor has when they arrive on your site.


Saturday, May 21, 2016

How to Auto-Publish WordPress Posts to LinkedIn

Do you want to auto-publish your WordPress posts to LinkedIn? LinkedIn is a social network of professionals and a very strong platform to bring traffic to your WordPress site. In this article, we will show you how to auto-publish WordPress posts to LinkedIn.


Automatically publish WordPress posts to LinkedIn


Method 1: Auto Publish WordPress Posts to LinkedIn using IFTTT


IFTTT is short for If This Then That. It is a web service which allows you to connect your other online accounts and make them work for you. For more information, take a look at our guide on how to automate WordPress and social media with IFTTT.


First thing you need to do is sign up for an IFTTT account. Simply visit the IFTTT website and click on sign up.


IFTTT Signup


After signup, IFTTT will show you how it works. Just follow the on screen instructions until you reach the IFTTT dashboard.


It will look something like this:


IFTTT Dashboard


A process created by IFTTT is called a recipe. Click on 'My Recipes' link at the top to create your first IFTTT recipe.


IFTTT My Recipes


This is the page where all your IFTTT recipes will be displayed. Simply click on 'Create a recipe' button to continue.


IFTTT recipe


An IFTTT recipe consists of two parts. The first part is called 'This', which is a trigger that will start the IFTTT recipe. But before IFTTT can fire a trigger, you need to tell it where to look for the trigger.


Click on 'this' to get started.


IFTTT will now show you all the channels you can use for your trigger. You need to type WordPress in the search box and then select it as your trigger channel.


Select WordPress as your IFTTT trigger channel


IFTTT will ask you to connect your WordPress site. Simply click on the connect button to continue.


A popup window will appear on your screen, where IFTTT will ask for your WordPress website information.


Connecting your WordPress site to IFTTT


You need to enter your WordPress site's address, your WordPress username and password. Click on the connect button to continue.


IFTTT will now try to connect to your WordPress site. Upon success it will show you a success message. Click on Done button to close the popup, and then click on 'Continue to next step' button.


IFTTT will now ask you to choose from the available triggers. You can launch an IFTTT trigger when any new post appears on your WordPress site or when a new post is published in a specific category or tag.


Right now we will be using 'Any new post' as our trigger. Simply click on the 'Any new post' box to continue.


Choose any new post as your trigger


IFTTT will now ask you to confirm. Simply click on Create trigger button to move on.


The next step is to choose what action to take when this trigger is fired. Click on 'that' link to define the action when a new post appears on your WordPress blog.


IFTTT That


First you will need to choose a channel where your action will take place. Search and select LinkedIn as your action channel.


Choose LinkedIn as your action channel


IFTTT will ask you to connect your LinkedIn account. Simply click on the connect button and a popup will appear which will take you to the LinkedIn website.


Enter your LinkedIn login details and then click on 'Ok, I'll allow it' button.


Authorize IFTTT to access your LinkedIn account


IFTTT will show you a success message. Click on the done button to close the popup and then click on continue to next step button.


You will now choose the action. You can share an update on your LinkedIn profile, or you can share a link.


Choose an action


Click on share an update on LinkedIn profile to continue.


IFTTT will ask you to choose action fields. It will automatically show your post title and URL fields in the status box.


Action fields


Simply click on create action button to finish your recipe.


IFTTT will now show you a summary of your recipe. You need to click on the create recipe button to make your recipe live.


Create and add recipe


That's all, your IFTTT recipe is now live. It will automatically check your WordPress site for new posts and will share them as a status update on your LinkedIn profile.


When sharing a post, LinkedIn will automatically use your post's featured image as thumbnail.


Your WordPress to LinkedIn recipe on IFTTT


You can always see your recipe by visiting my recipes page. You can also edit, stop, or pause a recipe at anytime.


Method 2: Auto Publish WordPress Posts to LinkedIn using Plugin


You can also automatically share your WordPress posts to your LinkedIn profile using a WordPress plugin.


First thing you need to do is install and activate LinkedIn Auto Publish plugin. For more details, see our step by step guide on how to install a WordPress plugin.


Upon activation, the plugin will add a new menu item labeled 'LinkedIn Auto Publish' to your WordPress admin menu. Clicking on it will take you to plugin's settings page.


LinkedIn auto-publish settings


The settings page will show you two URLs from your own site and a link to create a new LinkedIn app. For this plugin, you will need to create a LinkedIn app to get client and secret API keys.


Simply visit LinkedIn Developer's website and click on create application button.


Create a LinkedIn app


This will bring you to the application form for creating a new app. First you need to provide company name, a name for your application, and description.


You will also need to upload a logo for your application. You can use your blog's logo or any other image for this purpose. The image needs to be square with the same width and height.


Create new app application form


Lastly, you need to provide your website address, business email, and a phone number. Check the terms and conditions box and then click on submit button.


LinkedIn will now create your app, and it will take you to the app dashboard. You will find your client ID and client secret keys there.


LinkedIn API Keys


But you still need to add authorized redirect url on your app's dashboard.


Scroll down a little and you will find 'OAuth 2.0 Authorized Redirect URLs' field. Copy and paste the second URL from plugin's settings page here and click on the Add button.


Redirect url


Don't forget to click on the update button to store your app settings.


Now simply copy and paste Client ID and Client Secret keys from your app page to plugin's settings page. After that, click on save button to store your plugin settings.


Your WordPress site is now ready to connect to your LinkedIn account. Click on the 'Authorize' button at the top of your plugin's settings page.


Authorize app


This will take you to LinkedIn website where you will be asked to allow access to the app you created earlier.


Allow access


Enter your LinkedIn login credentials and click on Allow access button. LinkedIn will now redirect back to your WordPress plugin's settings page which will show a success message. The authorize button will now change into reauthorize.


That's all, LinkedIn Auto Publish plugin will now automatically share your WordPress posts to your LinkedIn profile.


You will also find a new meta box below your post editor screen when editing a post. You can disable or change sharing settings for individual posts from this meta box.


Linkedin Auto Publish meta box on post edit screen in WordPress


We hope this article helped you auto-publish WordPress posts to LinkedIn. You may also want to see our list of 10 LinkedIn WordPress plugins to win new customers.


If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.


The post How to Auto-Publish WordPress Posts to LinkedIn appeared first on WPBeginner.


The Ultimate Guide to 404 Pages for WordPress

Bad 404 pages are like trampolines for your WordPress site: Visitors who land on them are going to bounce. How you deal with 404s will determine whether visitors stick around or check out the competition when they end up on a page that WordPress can't find.


404 errors aren't unique to WordPress. The 404 message is the standard error code returned by a web server when a requested webpage can't be located. Basically, a 404 means the server is working just fine, but the requested webpage is nowhere to be found.


This post will help you get a handle on your 404s. I'm going to explain:



  • How 404s happen,

  • How the WordPress core deals with 404s,

  • How themes are designed to pretty up 404 pages, and

  • What you should do to make sure that a visitor who lands on a 404 has the best chance possible of sticking around rather than bouncing off your site.



Why Do Bad 404s Happen to Good Websites?


While 404s aren't unique to WordPress sites – they will happen regardless of the application running your website – they certainly are very easy to create when working with WordPress. WordPress makes it really easy to tweak page URLs and change the post permalink structure to fit your preferences and SEO objectives, but this also makes is way too easy to break a lot of links very quickly.


If you have a website with published posts and you change your permalink structure, every link to a post on your web page will break. The same scenario can play out when working with pages. Let's say that you accidentally publish a page with the URL http://www.yourdomain.com/our-produtcs. Three weeks later, you realize you misspelled products, head for wp-admin, and fix the spelling of products in the URL.


Well, that was easy! Yay WordPress! A simple 30-second fix, right?


Nope. Absolutely not. You just broke every link on your site or any other site that pointed to your misspelled URL.


So what in the world should you do? Put up with the misspelled URL? I know I couldn't do that. Read on and we'll sort it out.


standard 404 page displayed by twenty sixteen theme

How Does WordPress Handle 404s?


Whenever WordPress finds that a page or post has been requested but does not exist, the WordPress core checks for two theme files: 404.php and index.php. If WordPress finds that the active theme has a 404.php template, it will display that template. If no 404.php is found, WordPress will load the theme's default index.php file and follow the instructions at the end of the loop telling WordPress what to do when no content can be found.


Most themes include a 404.php template. You can find your theme's 404 template by going to wp-content/themes/active-theme and looking for 404.php. When it comes to working with WordPress 404 pages, 404.php is the place to start.


In most cases, the 404 page that ships with your template will say something pretty generic and provide a search prompt that the visitor can use to try and locate the content they are trying to find. There is so much more you can do with your 404 page but before you start designing you need to think about your strategy.


What is Your 404 Page Strategy?


Before you start creating redirects or building out a witty 404 page that's sure to wow your visitors, take a minute and think about your strategy. When it comes to 404 pages, you have a couple of things to consider:



  • Where are the 404s coming from? Can you find and fix the links that are sending visitors to dead-ends?

  • What should you do with your 404 page so that visitors stick around instead of bouncing to a competitor when they see it?

  • If you know where some visitors were trying to go when they got the 404 page instead, should you redirect those visitors to the correct URL?


Your best strategy is to find ways to answer all three of these questions. First, locate broken internal links and fix them. Next, create a 404 page that encourages visitors to stick around and helps them find what they are looking for. Third, identify URLs that are repeat offenders for generating 404s and permanently redirect those URLs to the correct web page.


Let's look at these problems one at a time and figure out how we can fix them.


How to Locate and Fix Broken Links


There are two different paths that visitors might take to land at a 404 on your website:



  • By following an internal link between pages and posts on your site.

  • By following an external link from another website to a page or post on your site.


At this stage in the process, what we're worried about are broken internal links. Broken external links you can fix in a later step with a permanent redirect. However, right now you need to find a way to check every link on your website and determine which, if any, are sending visitors to a hard 404 landing.


Here are five tools you can use to check for broken links on your website.


  • Google Search Console

    google-search-console

    Google Search Console, if you don't already know, is a free suite of Google products used to monitor the information Google has gleaned while crawling your site. One of the things Google reports back is any broken links found while crawling. To see the broken links Google has found log into Search Console, bring up the property you're managing, and select Crawl > Crawl Errors from the menu on the left. Then click on the Not found tab to see the broken links Google thinks it has found.


    I should point out that dealing with crawl errors in Search Console could stand to be an article all on it's own. So we won't go into depth on that topic right now. Thankfully, Google has a pretty good support site you can use to learn more about interpreting and addressing the crawl errors you see in Search Console.


  • W3C Link Checker

    w3c-link-checker

    This is a free link checker from the W3C and Mozilla. Enter any URL to check the content of the returned document for broken links. You can even check linked documents if you'd like–a metric called recursion depth. However, checking links recursively can end up taking a lot of time and generating a stack of results too overwhelming to tackle.


    Start by checking one page at a time and fixing any broken links you find as you go. If it's going pretty well, set the recursion depth to 1 and see how that goes. While you're at it, keep in mind that this tool will look at things like the links between plugins and any servers they connect to. In most cases, these types of links will show up as broken links. What you're really looking for are links to other pages and posts on your site that show up as broken. Find and fix those broken internal links.


  • Broken Link Checker

    broken-link-checker

    This free plugin from the WordPress plugin directory continually monitors your site for broken links and lets you know as soon as any are found. One of the best features of the plugin is that you can fix broken links directly from the plugin page which can be a huge convenience if you need to fix links in a dozen different posts. With over 400,000 active installations, this is by far the most popular link checking plugin at WordPress.org.


  • WP Broken Link Status Checker

    wp-broken-link-status-checker

    This plugin will check all of the links on your site looking for broken links, redirects, nofollow links, and more. To check links, you create a configurable link scanning operation and then either run it immediately or save it and run it at a later time. Scanning your entire database and website can be a resource intensive process, so this plugin is designed to avoid affecting user experience by prioritizing user traffic over any queries performed by the plugin.


  • Link Checker

    link-checker

    If you're worried about the impact checking links might have on your website's performance, Link Checker is an alternative worth considering. An external server run by the plugin developer does most of the heavy lifting so that all your server sees is a web crawler taking a look at each page. The free version of this plugin will check up to 500 links. If you need to check more links than that, consider a different plugin or look at the professional version of Link Checker.



How to Build a Better 404 Page


Unless you permanently redirect your 404 page (and you really shouldn't do that) it's impossible to completely eliminate 404 errors. Even Google agrees with that.


The best thing to do is to create a great 404 page. If you need some inspiration take a look at some of the greatest hits lists put together by the likes of Hubspot and Time, Inc.


404 pages are an opportunity to show some personality while also helping your visitor find what they're looking for. The best 404 pages are often self-deprecating, humorous, and make a play on the content of the site or the industry of the company behind the website.


Take a minute and think what you want to accomplish with your 404 page and how you can communicate that goal in a fun way. Then take a look at these tools which you can use to spruce up your 404 page.


  • WordPress Codex: Creating an Error 404 Page

    codex

    The classic method for crafting a great 404 page is by modifying the 404.php template included in your theme, or by creating one if your theme doesn't include a 404 page template. The WordPress Codex includes a very good tutorial that will show you how to do this. However, if you aren't familiar with PHP and HTML, the rest of the tools in this list are probably a better option.


  • Upfront

    upfront

    The first time I used an Upfront theme I was a bit perplexed about how to modify the theme's 404 template. Then I found a post in our support forum on the topic and it became clear to me: modifying a 404 page in Upfront could not possibly be any easier. If you're using Upfront, make sure you're logged in and navigate to any URL on your domain that doesn't exist, such as http://www.yourdomain.com/nonsense-and-whatnot. Once the 404 page loads, click Upfront from the admin bar at the top of the page and you'll have complete artistic license to create whatever you want to display as your 404 page.


  • 404page

    404page

    404page is one of the most popular custom 404 page plugins in the WordPress plugin directory, and for good reason. First, it doesn't create a redirect which can mask larger structural problems. Second, it doesn't require any additional HTTP requests, which can impact page load speed.


    With 404page you just create a new page, design it as you wish, and then adjust the plugin settings to set that page as your designated 404 error page.


  • Custom 404 Pro

    custom-404-pro

    Coming in a close second to 404page in terms of the number of active installs, Custom 404 Pro is another well-vetted plugin you can use to build a custom 404 page. Like 404page, with Custom 404 Pro you first build a new page and then adjust the plugin settings to designate that page as the one to display when a 404 error is encountered.


  • 404 Page by SeedProd

    404-page-by-seedprod

    With 404 Page by SeedProd you can quickly input a few key values, such as the message to display, a background image, and whether or not to display the search prompt, and a completely custom 404 page will be generated. You can even set the plugin to take a screenshot of your homepage and to use that screenshot as the 404 page background. If you want to create a 404 page that breaks out the mold of the rest of your website's layout, this plugin makes it easy.


  • Forty Four

    forty-four

    Forty Four is a lot like 404 Page by SeedProd. You can use the plugin to generate a completely unique 404 page complete with background, search prompt, custom message, and more. However, one way that it stands out from the other options on this list is that Forty Four has configurable redirects. So, if you want search engines to show a 301 redirect, but your visitors to see your 404 page, Forty Four will let you do that.



How to Redirect Frequent 404 Fliers to Related Content


Earlier in this tutorial, I brought up a “fictional” situation involving a misspelled URL that could result in broken links and visitors landing at 404 pages. In that “fictional” scenario the right thing to do would be to permanently redirect the old misspelled URL to the corrected URL. Doing so has two benefits:



  • Visitors who land at the old URL skip the 404 page and are shown the page located at the new URL.

  • Search engines interpret the permanent redirect correctly and index the new URL in place of the old one.


There are other scenarios that might cause similar problems. For instance, let's say that you publish an update to a previous blog post and no longer want visitors to read the older post since it contains outdated information. That happens on this blog from time to time. WordPress is a rapidly changing platform, and we want our visitors to get the most up-to-date information from our site. As articles grow outdated we redirect them to updated articles that cover the same topic. In cases like these, a permanent redirect from the outdated post to the updated post is good form.


Another common way for 404s to show up is when another website links to yours and misspells part of the URL. You can usually look at the URL and figure out pretty quickly which web page they meant to link too. A permanent redirect from the misspelled URL to the intended URL will ensure that traffic from that site lands where it's supposed to.


I don't recommend redirecting all 404 traffic. I think it's a better practice to create a great 404 page and to let it serve its purpose. However, for that percentage of your traffic that you should redirect–such as visitors reaching your site using a known broken or outdated link–it's best to redirect them to the content you know they're trying to reach.


There are lots of plugins available that promise to redirect all 404 traffic to your site's homepage or another page on your site. However, I'm not a big fan of blanket redirection. So rather than show you any of those – which you can certainly find if that's what you're looking for – here are three redirection plugins that take a more nuanced approach.


  • Redirection

    redirection

    When it comes to creating and managing redirects, there isn't much Redirection can't do. It's free, available from the WordPress plugin directory, and active on over 500,000 websites. Redirection automatically logs every time a visitor lands on a 404 page so you can easily identify URLs that consistently generate 404 errors and create permanent 301 redirects to address those URLs. Redirection can even create an automatic 301 redirect when a post URL changes so you don't have to create it manually.


  • Redirect 404 to Parent

    redirect-404-to-parent

    This plugin implements a novel approach to the issue of 404s. The way this plugin works is that all URLs that generate a 404 error code are redirected to the parent URL. This is a little tricky to understand, and an example will help. After installing the plugin, you would create redirection base URLs like this: http://www.yourdomain.com/parent_page/. After setting up that record, any 404 generated that contained that base URL would be redirected to the parent URL. So if someone tried to go to http://www.youdomain.com/parent_page/nonsense-and-whatnot they would be redirected to the parent URL, http://www.yourdomain.com/parent_page/.


    Each redirection is logged so that you can create permanent 301 redirects for repeat offenders.


    With this plugin you can set up multiple base URLs making it a great option for highly heirarchical WordPress sites that make heavy use of parent and child pages.


  • Eggplant 301 Redirects

    eggplant

    Eggplant 301 Redirects is designed to make it easy to create 301 redirects from old URLs to new ones. Bulk redirects can be uploaded in CSV format in situations where you need to redirect a large number of URLs–such as when purchasing a site and overhauling the URL structure. While the free version of Eggplant does all of this well, the real power of this plugin is in the 404 error logging which you don't get unless you purchase the Pro version.



Parting Thoughts


Any time a visitor lands on a 404 page, something has gone wrong. However, that doesn't mean that all is lost.


Make the most of a bad situation by fixing broken links, crafting an effective 404 page, and using redirects to permanently fix URLs that generate 404s on a regular basis.


What is your 404 strategy? Do you have a 404 page your particularly proud of? Let us know in the comments.