优选主流主机商
任何主机均需规范使用

如何在WordPress中不使用插件实现链接跳转功能

链接形式http://localhost/?go=http://www.jb51.net这种形式转跳的方法。

代码如下:

add_action(‘wp_head’, ‘gourl’);

function gourl() {

global $pagenow;

if (is_home && $pagenow == ‘index.php’) {

$location = $_GET[‘go’];

if ($location != “”) {

wp_redirect(esc_url_raw($location), 302);

exit;

}

}

}

复制上面的代码到主题的functions.php文件即可实现wordpress链接转跳功能。

未经允许不得转载:搬瓦工中文网 » 如何在WordPress中不使用插件实现链接跳转功能