admin管理员组文章数量:1406944
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.
Share Improve this question edited Nov 25, 2019 at 14:09 butlerblog 5,1213 gold badges28 silver badges44 bronze badges asked Nov 25, 2019 at 3:16 John McIntyreJohn McIntyre 331 silver badge4 bronze badges2 Answers
Reset to default 10In 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.
本文标签: Why does WordPress automatically redirect URLs with the parameter quotnamequot to a different page
版权声明:本文标题:Why does WordPress automatically redirect URLs with the parameter "name=" to a different page? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744970031a2635177.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论