WordPress Non-Plug-in Implementation of Adding Link Jump Function

Time:2019-9-11

Link form http://localhost/?Go=http://www.baidu.com.

Copy code

The code is as follows:

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;
}
}
}

Copy the above code to the functions. PHP file of the theme to achieve WordPress link jump function