I need to use javascript redirection in one of my scripts. With /%postname%/
WP permalinks structure redirection works like it should but with default it always redirects to home page.
/%postname%/
structure script:
window.location.replace(encodeURIComponent(""));
default permalinks structure script:
window.location.replace(encodeURIComponent("/?customposttype=postslug"))
I need to use javascript redirection in one of my scripts. With /%postname%/
WP permalinks structure redirection works like it should but with default it always redirects to home page.
/%postname%/
structure script:
window.location.replace(encodeURIComponent("http://www.url/customposttype/postslug"));
default permalinks structure script:
window.location.replace(encodeURIComponent("http://www.url/?customposttype=postslug"))
Share
Improve this question
asked Mar 18, 2014 at 19:20
raaaaraaaa
232 silver badges7 bronze badges
6
|
Show 1 more comment
1 Answer
Reset to default 1The issue is that your script is doing a replace, but really what you want is to set the window location:
Change your redirects from:
window.location.replace(encodeURIComponent("http://www.url/?customposttype=postslug"))
to
window.location = "http://www.url/?customposttype=postslug";
And it should work properly.
http://www.url/?customposttype=postslug
into your browser? – random_user_name Commented Mar 18, 2014 at 20:13