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?
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?
Share Improve this question edited Jun 18, 2020 at 17:02 Mort 1305 9835 silver badges18 bronze badges asked Jun 17, 2020 at 16:01 Neal BozemanNeal Bozeman 1012 bronze badges 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 Commented Jun 17, 2020 at 16:32
1 Answer
Reset to default 0Just 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';
});