wordpress如何添加链接跳转
方法一:
粘贴以下代码到主题的functions.php文件即可实现wordpress链接转跳功能。
展现方式为:https://www.uoo2.com/?go=http://www.baidu.com这种形式转跳。
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;
}
}
}
相关推荐:《WordPress教程》
方法二:
同样粘贴以下代码到主题的functions.php文件中。不过要在编辑文章时添加一个名称为ruikeedu_gometa的自定字段,值为:你需要转跳的目标页链接。
展现方式为:http://www.uoo2.co/?goid=123这种形式转跳。
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;
}
}
}
}
以上就是wordpress如何添加链接跳转的详细内容,更多请关注双恒网络其它相关文章!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。



