wp页面重定向模板

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?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.';
 
     }
?>

http://snipplr.com/view/24727/wordpress-page-redirect-template/

喜欢这篇文章吗?

请订阅本站 RSS feed填写您的邮件地址,订阅我们的精彩内容:

相关日志

回复 (0)

› 尚无评论。

发表评论 修改评论取消编辑

允许使用的标签 - 您可以在评论中使用如下的 HTML 标签以及属性。

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 :wink:  :-|  :-x  :twisted:  :)  8-O  :(  :roll:  :-P  :oops:  :-o  :mrgreen:  :lol:  :idea:  :-D  :evil:  :cry:  8)  :arrow:  :-?  :?:  :!:

引用通告 (0)

› 尚无引用通告。

开灯