I am learning so much about SEO these days and I started wondering how a custom 404 page could help improve the user experience.
I started searching articles about how to customize the 404 page in GeneratePress and I discovered that you can do that easily with elements.
To use elements, you need to have GeneratePress Premium on your WordPress site.
In addition to elements, you can use add code snippets to remove the default search form and other data included by default in it.
Let’s explore all that you need to fully customize your 404 page with the help of GeneratePress Elements and the code snippets plugin
Table of Contents
- 1 Elements in GeneratePress to have a Custom 404 Page
- 2 Remove 404 Page Title in GeneratePress
- 3 Code Snippet to Remove Default Text from 404 Page
- 4 Code Snippet to Remove Search Form from 404 Page
- 5 No Code Snippets to Customize the 404 Page on GeneratePress
- 6 Source: GeneratePress Forum
- 7 Wanna Read More?
Elements in GeneratePress to have a Custom 404 Page
These are the steps to add content to your 404 page
- Go to Appearance then to Elements
- Add a new Element
- Choose “block” from the Element Type Options
- Write the title that you want
- Build your page using GenerateBlocks or any other plugins
- When you finish, go to the display rules section
- For the location, choose “404 Template”
- In the block element setting choose “Hook” for the element type
- For the hook name Choose “after_main_content”

You can play with this section and build a nice 404 page doing what you do with the rest of the pages of your site
Remove 404 Page Title in GeneratePress
If you don’t have any plans for the 404-page title, you can use this code snippet and get rid of it
add_filter( 'generate_404_title','remove_404_title' );
function remove_404_title()
{
return '';
}
Code Snippet to Remove Default Text from 404 Page
This is a code snippet to remove the text before the search form
//Remove 404 Custom Text
add_filter( 'generate_404_text','generate_custom_404_text' );
function generate_custom_404_text()
{
return '';
}
Code Snippet to Remove Search Form from 404 Page
This is a code snippet to remove the search form from the body of the page
//Remove 404 Search Form
add_filter( 'get_search_form','my_remove_search_form' );
function my_remove_search_form()
{
$template = $GLOBALS['template'];
$template_file = substr($template, strrpos($template, '/') + 1);
if ($template_file === '404.php') {
return '';
}
}
No Code Snippets to Customize the 404 Page on GeneratePress
If you don’t find any uses for the content section now that you have removed the default text and search form, you can get rid of everything and use your custom 404 template as a content template.
This is what you have to choose as “element type”

Remember to choose “404 template” for location on display rules.
You also have to apply full width to the template so your 404 doesn’t look like crap on big screens, you can do that by using the “Layout Element”
- Add New Element
- Choose Layout
- Create
- Go to the Content Tab
- In Content Area, tick the ” Full Width (no padding)” option
- Now go to the “Display Rules” tab and choose “404 Template” for the location
- Done
Source: GeneratePress Forum
I tested all code snippets using the Code Snippets Plugin and it works like a charm
By the way, use the Code Snippets Plugin, don’t add code to the functions.php unless you have activated the child theme because those codes will be gone whenever you update your theme
Give credit to Marquis M who made this contribution to the GeneratePress Forum
Wanna Read More?
These are some posts that you might find helpful if you have a WordPress site
- Protect your WordPress Site with Cloudflare Firewall Rules
- SG Security: SiteGround Security Plugin
- WordPress Security without Plugins
- How to Optimize GeneratePress for Core Web Vitals [100% Solved]
- How to Use Flying Scripts to Speed up Your WordPress Site
- How to Improve the Page Speed of Your Adsense Sites
- How to Use Cloudflare Full Page Caching With WordPress