I cannot reproduce what you describe. I have a WordPress 6.0.1 with TwentyTwentyTwo as theme and no plugins enabled. If I call there then a URL with ?name=example comes a 404 page.
The parameter name is a protected parameter in WordPress. It is used by WordPress for query vars, see: https://codex.ww.wp.xz.cn/WordPress_Query_Vars
If you want to customize this (for whatever reason), you could possibly start with this hook: https://developer.ww.wp.xz.cn/reference/hooks/removable_query_args/
Hi threadi
actually you must test it just on homepage of your site
not another pages
it hurts SEO if you show something else with query string on your site (specially on your homepage) instead of the main content
basically as you said when you enter the url of homepage with /?name you should see the homepage and nothing should change because it’s just a query string
I can show you an example
see this : https://amepro.at/
as you see everything is fine and homepage of website is ok
but please see this one https://amepro.at/?name
here you see the blog posts and it hurts SEO very bad
I got too much errors on search console with these kind of urls
I saw all protected query vars
all of those parameters should remove because this action is not SEO Friendly at all
you can’t show visitor something on homepage and show something else with query strings like this
Ah, now I’ve got it. What you describe happens when you add a parameter without a value. So only ?name instead of ?name=example
I don’t see a connection with SEO. There would have to be links to such URLs so that search engines could find and index them at all. I don’t know any project where this is the case.
If you intentionally use parameters in the URL, then you should control them exactly – many plugins that do this use their own query vars, of course. And those actually always have a value as well. Not no value as in your example.
I was wrong with my hook tip above, unfortunately. To clean up the public query vars you could use this filter here:
function remove_query_vars( $query_vars ) {
return [];
}
add_filter('query_vars', 'remove_query_vars');
This will display the start page when you call the link you found. However, this could mess up some other things on the system, so I wouldn’t recommend doing this.
Can you explan the logic behind it why should we show another thing like latest post when someone enter some parameter ?
it’s not normal at all
-
This reply was modified 3 years, 10 months ago by
masimoti.
I dont wanna use the code you sent because as you said it may cause another problem
Unfortunately I can’t explain this, I’m not that deep in the wordpress code (yet). Maybe you could open a ticket in Trac so that core-developers could answer this: https://core.trac.ww.wp.xz.cn/newticket
429 Too Many Requests
I got this when I wanted to publish a ticket there
would you please ask them?
Unfortunately no. Please try again later.