|
 
- 积分
- 6158
- 金钱
- 2941 WPB
|
其实真的不知道这个功能有什么用途,但是看到很多人提出来了,我想到这么个方法:
修改所使用的主题目录下的index.php文件,
找到这句,
- <h1 id="post-<?php the_ID(); ?>"><a href="<?php
- the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php
- the_title(); ?>"><?php the_title(); ?></a></h1>
复制代码
替换成,
- <?php
- $id = intval($post->ID);
- $link_to = $wpdb->get_var("SELECT meta_value FROM wp_postmeta WHERE meta_key = 'linkto' and post_id = $id");
- ?>
-
- <?php if ($link_to) : ?>
-
- <h1 id="post-<?php the_ID(); ?>"><a href="<?php echo $link_to; ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
- <?php else : ?>
-
- <h1 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
- <?php endif; ?>
复制代码
在写 文章时添加一个自定义字段,字段名写linkto,字段值写要跳转的网址(要写完整网址,即加http://的),就ok了。 |
附件: 您需要登录才可以下载或查看附件。没有帐号?注册
|