I would like to build a website where all page URLs point to the homepage.

Wordpress already shows URLs like


as a 404 page. However, instead of the 404 error, I would like it to just show the homepage, while maintaining the URL in the browser's address bar.

How can I achieve this?

  • 1
    So basically you still have a 404 server error but with a front page template. You could copy all front-page.php content inside 404.php. Don't forget to check if you have any enqueue that is specific for front page, and add a is_404() check as well Aug 13 at 13:31

EDIT 2: You could also make a function to load your front-page.php template for 404 pages. See below:

add_filter('template_include', function($template) {
    if ( is_404() ) {
        return locate_template(['front-page.php']);
    return $template;

EDIT: I read over the fact that you want to keep the URL as is. Why is that if I may ask?

You could make a redirect from your 404 page to your homepage. Just edit (or create if it doesn't already exists) your 404.php file within your theme or child-theme folder. Below snippet redirects all 404's to your homepage:


header("HTTP/1.1 301 Moved Permanently");

header("Location: " . get_bloginfo('url') );



I usually don't recommend this, but I'm going to assume you have a good reason for it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.