Home >CMS Tutorial >WordPress >How to add link jump in wordpress

How to add link jump in wordpress

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-07-15 15:36:563610browse

How to add link jump in wordpress

Method 1:

Paste the following code into the theme’s functions.php file to achieve wordpress link jump Function.

The display method is: https://www.uoo2.com/?go=http://www.baidu.com This form of redirect.

add_action('wp_head','ruikeedu_gourl');    
function ruikeedu_gourl(){    
global $pagenow;    
if(is_home&&$pagenow=='index.php'){    
$location=$_GET['go'];    
if($location!=""){    
wp_redirect(esc_url_raw($location),302);    
exit;    
}    
}    
}

Related recommendations: "WordPress Tutorial"

Method 2:

Also paste the following code into the functions of the theme. php file. However, you need to add a custom field named ruikeedu_gometa when editing the article. The value is: the link to the target page you want to jump to.

The display method is: http://www.uoo2.co/?goid=123 This form of jump.

add_action('wp_head','ruikeedu_gometa');    
function ruikeedu_gometa(){    
global $pagenow;    
if(is_home&&$pagenow=='index.php'){    
$postID=$_GET['goid'];    
if($postID){    
$postID=(int)$postID;    
$location=get_post_meta($postID,'ruikeedu_gometa',true);    
if($location!=""){    
wp_redirect(esc_url_raw($location),302);    
exit;    
}    
}    
}    
}

The above is the detailed content of How to add link jump in wordpress. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn