WordPress新建页面跳转到指定URL网址
在Wordpress现有的主题下,新建redirect.php文件模版,在文件中添加如下内容:
<?php/*Template Name: Redirect*/
if (have_posts()) {the_post();$pattern = ‘@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@’;preg_match($pattern, get_the_excerpt(), $matches);if ($matches[0]) header(‘Location: ‘.$matches[0]);else echo ‘Enter a URL into your page body text.’;}?>
保存文件。然后到Wordpress控制台,新建页面,在页面内容中添加你要转到的网址url,最后在编辑页面的右下角,选择页面模板为“Redirect”,保存发布页面就可以了。
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:23
阅读量:123
阅读量:167
阅读量:116
阅读量:33