0

I want /url1, /url2, /url3, to all behave as though the homepage / was accessed, and to have the homepage rendered without redirecting away from /urlx. In fact, if every URL someone tried to access was rendered as the home page, that would be great.

No need for SEO advice, or learning about redirects to the canonical page. This is a special use-case and I need this specific outcome.

I have tried resetting the query by hooking in to pre_get_posts() and calling wp_reset_query(), but that doesn't change any functionality on any page.

add_action( 'pre_get_posts', function($query) {
    wp_reset_query();
} );

Even if I could get every page on my site to render as the home page without redirecting, I could make the rest of the changes I need. Can anyone help?

1
  • If you only have a homepage and no other content, you could create a custom theme where the only PHP file is "index.php." This would force WP to render the same content no matter what URL someone landed on.
    – WebElaine
    Jun 17 '20 at 16:32
0

Just intercept the hook to determine which template to use. To make all pages act as the homepage:

add_filter( 'template_include', function($template) {
    return get_template_directory() . '/index.php';
});

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.