要领一:
粘贴以下代码到主题的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怎样增加链接跳转的细致内容,更多请关注ki4网别的相干文章!