方法一:
粘貼以下代碼到主題的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;???? }???? }???? }???? }
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END
喜歡就支持一下吧
相關推薦