Forums

Custom 404 not involving wordpress (4 posts)

  1. Xfactory
    Member
    Posted 3 years ago #

    I understand that if you have a theme with a 404 page you can use that to customize but what if you don't want wordpress to use the 404 page that comes with the them and just want to use your own is there a way to prevent wordpress from calling the 404.php page within the theme?

  2. ClaytonJames
    Member
    Posted 3 years ago #

    I think you might be able to just add an ErrorDocument line to your .htaccess.

    ie... ErrorDocument 404 /path_to_local_file/filename.php (or html)

    I'm not sure whether or not you will need to rename, or delete the theme's custom 404 page. Here is a reference for custom 404 page in WordPress, if that's any help.

  3. davesgonebananas
    Member
    Posted 3 years ago #

    You can hook the '404_template' filter and return the path to the template you want it to use or false if you don't want any output.

    function override_404_template( $template ) {
      return '/var/www/errors/404.php';
    }
    
    add_filter('override_404_template', '404_template');
  4. Xfactory
    Member
    Posted 3 years ago #

    Do I delete the themes 404 ? I have already created a custom 404 error page. Dave, where do those lines of code go my HTACCESS so I can try see if it works?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.