• Skip to primary navigation
  • Skip to main content

RocketGeek

Home of WP-Members, The Original WordPress Membership Plugin

  • WordPress Plugins
    • WP-Members
      • FAQs
      • Quick Start
      • Documentation
      • Extensions
    • Advanced Options
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Download Protect
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Invite Codes
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • MailChimp Integration
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • PayPal Subscriptions
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Salesforce Web-to-Lead
    • Security
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Text Editor
      • Purchase the Plugin
      • Get the Pro Bundle
    • User List
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • User Tracking
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Memberships for WooCommerce
    • WordPass
  • Blog
    • Basics
    • Tips and Tricks
    • Filters
    • Actions
    • Code Snippets
    • Shortcodes
    • Design
    • Release Announcements
  • Store
    • Cart
    • Checkout
  • Contact
  • Log In
  • Show Search
Hide Search
Home » Basics » Create a Custom 404 Page

Create a Custom 404 Page

Chad Butler · Dec 5, 2018 ·

This article is provided free. Find out how you can get full access to premium content, including how-to articles and support forums, as well as priority email support and member exclusive plugin extensions..

 

WP-Members offers the ability to “hide” content from non-registered users.  When content is hidden, it is as if the content does not exist if the user is not logged in.  That results in a 404 – which basically is a “not found” message.

But a generic 404 message like “Oops! That page can’t be found” may not be exactly what you want.  In that case, you will want to create a custom 404 template.  

Most themes will contain a 404.php template for display when a 404 is generated.  It’s a good practice to customize the 404. This is an opportunity for you to promote specific sections of your site – provide a message, some links, perhaps a search.

In some cases, the theme’s default 404.php may contain information you do not want to provide to the user. One example of this might be if you are using WooCommerce and have products you don’t want non-logged in users to see, but you’re using the default Storefront theme 404 template.  If that’s the case, you definitely want to make sure your 404.php is customized.

How do you create a custom 404.php template?

First, you should be using a child theme.  It’s a best practice to not make custom edits to core theme files.  Just as you shouldn’t to edit a core plugin file, you likewise shouldn’t edit the theme directly.  In the case of themes, any customization should be done in a “child theme.”  If you do not have a child theme set up, read this article on how to set on up.

If your child theme does not yet have a file 404.php, look in your parent for 404.php.  Copy (don’t cut/delete) that file to your child theme.  Open it and begin customizing what you need.

There is no specific content you need to put into a 404 page, but it’s often a good idea to include some links that you want to promote to a user.  Customize the 404.php template accordingly to take out what you don’t want and add in what you do want, whether that’s links, a general message, a search, or whatever.

If your site includes content you have marked as hidden using WP-Members, you might also want to include a message that indicates something to the effect “It’s possible the content you requested is only accessible to registered users.”

Remember, these are just ideas and concepts – it’s up to you to determine what you want your 404 to look like and the content you want it to contain.

What about redirecting a user?

I don’t recommend this.  If your redirection accidently results in a 404 error, the user ends up in an endless loop and thus a server 500 error (white screen of death essentially).  That’s a worse user experience than a 404 and gives you no opportunity to give information to the user (like links you want to promote, a search tool, or a site map).  But if you’re dead set on doing it that way, I have some code snippet examples that will give you a starting point on redirecting 404s.

Basics basics, child-theme, themes

Ready to get started?

Join Today!

© 2025 · butlerblog.com · RocketGeek is built using WordPress, WP-Members, and the Genesis Framework

  • butlerblog.com
  • WP-Members Support Subscription
  • Terms of Service
  • Privacy Policy
  • Refund Policy