[英]How to add target=“_blank” into a URL in php on Wordpress
I have used the following codes to add target="_blank" to a URL (password-reset page) on my website: 我已使用以下代码将target =“ _ blank”添加到我网站上的URL(密码重置页)中:
add_filter( 'lostpassword_url', 'my_lost_password_page', 10, 2 );
function my_lost_password_page( $lostpassword_url, $redirect ) {
return home_url( '/password-reset/?redirect_to=target="_blank"' . $redirect );
}
}
It does not work as it still opens the same window when pressing that page URL. 它不起作用,因为在按该页面URL时它仍会打开同一窗口。
Can you please give a right direction? 您能给个正确的方向吗?
Try with below code i am not sure with below code but this is the only possible way. 尝试下面的代码,我不确定下面的代码,但这是唯一可能的方法。
//$redirect = "https://www.gooogle.com";
echo '<script>window.open(' . $redirect . ',"_blank");</script>';
I have updated the latest version of RegistrationMagic a momment ago, there is no need to edit the codes I posted above. 我在一分钟前已更新了RegistrationMagic的最新版本,无需编辑我上面发布的代码。 It is working as intended.
它按预期工作。 Many thanks especially for @Aki.
非常感谢@Aki。 However, if anyone could help guide how to insert that _blank into the above codes, that may be useful for many people.
但是,如果任何人都可以帮助指导如何将_blank插入上述代码中,则对许多人来说可能很有用。 Thanks
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.