To show a 404 page in WordPress, you can follow these steps:
- Create a new 404.php file in your WordPress theme directory: Open your theme's folder on your server, locate or create a file called "404.php", and add your custom message or design to this file. This will be the template for your 404 error page.
- Activate a dedicated error page plugin: If you don't want to edit code directly, you can use a plugin like "404page" to create and customize your 404 error page. Install and activate the plugin, and then go to Settings -> 404 Error Page to personalize your 404 page using the plugin's options and features.
- Customize the 404 message in your .htaccess file: If you are comfortable editing code and have access to your website's .htaccess file, you can add a custom ErrorDocument directive to show the 404 page. Open the .htaccess file in a text editor, and add the following line:
ErrorDocument 404 /path/to/your/404.php
Replace "/path/to/your/404.php" with the actual file path to your custom 404.php file.
- Use a Super Admin to redirect visitors: If you are running a multi-site network in WordPress and want to redirect visitors to a unique 404 error page for each site, you can use the Super Admin feature. Go to the Network Admin dashboard, select Sites, and edit the desired site. Then, go to Settings -> Reading and select a specific 404 page from the dropdown menu.
- Use a custom permalink for your 404 page: By default, WordPress uses the "page not found" slug in the permalink structure for 404 error pages. If you want a custom permalink, you can create a WordPress page with a custom permalink like "404-page" and use that as your 404 page. In your theme's folder, create a file named "404.php" and enter the following code:
Remember to create or modify the 404.php file in your theme's directory to control the content and design of your 404 error page.