How do I disable this automatic redirect of the name variable so that I can use it on my call booking landing page?
I'm setting up a call booking page here: /
I want to add the URL parameters "name" and "email" so I can automatically populate the form.
Problem is, when I add the "name" parameter, WordPress assumes I want to redirect to a page with the name in it.
For example...
/[email protected] redirects to the call booking page fine, but if I add a name field, it redirects to the most likely page on the website.
Therefore, /?name=John&[email protected] redirects to my podcast with John Carlton /
And /?name=Mary&[email protected] redirects to a lightbox popup with "Mary" in the title.
How do I disable this automatic redirect of the name variable?
I've tried disabling all plugins, but it doesn't work.
I've tried disabling that WordPress automatic guessing function, but it didn't work either.
It seems like there's two steps.
WordPress takes name= and redirects it to the most likely URL, so name=John redirects to themcmethod/john.
Then the other step kicks in, whereby if themcmethod/john is a 404, wordpress automatically redirects to the most likely page with "John" in the title.
Apparently the guessing function is good for SEO, so I don't want (or need, for that matter) to disable it. I just want to stop the name=John redirect.
How do I disable this automatic redirect of the name variable so that I can use it on my call booking landing page?
I'm setting up a call booking page here: https://www.themcmethod/talk/
I want to add the URL parameters "name" and "email" so I can automatically populate the form.
Problem is, when I add the "name" parameter, WordPress assumes I want to redirect to a page with the name in it.
For example...
https://www.themcmethod/talk/[email protected] redirects to the call booking page fine, but if I add a name field, it redirects to the most likely page on the website.
Therefore, https://www.themcmethod/talk/?name=John&[email protected] redirects to my podcast with John Carlton https://www.themcmethod/john-carlton-on-6-key-elements-of-powerful-profitable-email-marketing/
And https://www.themcmethod/talk/?name=Mary&[email protected] redirects to a lightbox popup with "Mary" in the title.
How do I disable this automatic redirect of the name variable?
I've tried disabling all plugins, but it doesn't work.
I've tried disabling that WordPress automatic guessing function, but it didn't work either.
It seems like there's two steps.
WordPress takes name= and redirects it to the most likely URL, so name=John redirects to themcmethod/john.
Then the other step kicks in, whereby if themcmethod/john is a 404, wordpress automatically redirects to the most likely page with "John" in the title.
Apparently the guessing function is good for SEO, so I don't want (or need, for that matter) to disable it. I just want to stop the name=John redirect.
In WordPress, name
is a reserved term (emphasis mine):
There is a complete set of reserved keywords, or terms, in WordPress that should not be used in certain circumstances as they may conflict with core functionality. You should avoid using any of these terms when:
- Passing a term through a
$_GET
or$_POST
array- Registering a taxonomy or post type slug
- Handling query variables
In this case, this is not just a redirect. Internally, all WordPress pages and posts are accessed via query parameters on index.php
, so whenever you access a URL like https://example/post-name/
, you're actually loading https://example/index.php?name=post-name
. So if you somehow changed WordPress so that posts were not accessible with the name
parameter, you'd break all of your post permalinks.
To avoid conflicts with WordPress, you should choose something else for your parameter, such as first_name
, or full_name
.
Add a pre_get_posts filter.
It looks like the following:
function do_this_before_stuff( $the_query_object ) {
if ( ! empty( $_GET['something'] ) ) {
$something = sanitize_key( $_GET['something'] );
$the_query_object->set( 'something', $something );
}
}
add_action( 'pre_get_posts', 'do_this_before_stuff' );
There's other good places to put actions/filters, but pre_get_posts
is a pretty great one.