如何对WP实现动态加载文章内容
著名的博客擦汗大师(不好意思,应该是插件大师,主题大师)mg12 在其博客上应用非正常手段JavaScript实现了动态加载文章内容。本淫在第一时间给予了关注,并也成功的把WP改造,顺利使用该功能了。现在花点时间把本淫的方法告诉大家。希望大家拍砖。

其实这个东西,主要是js来实现的.那么我们需要提供一个js文档.请到这里下载:点我的JJ.
需要一个图标文件,请到这里下载:点我的JJ
好了,将 第一个JJ(POST.JS)放到INOVE主题目录的JS目录中,将第二个JJ(icons.gif)放到INOVE主题目录的IMG目录中.
好了.现在开始改造了.我这里说的是INOVE主题,其他的自己研究下.
第一步,修改INOVE主题中的index.php文件:
有两条需要修改:
找到:
- <?php get_header(); ?>
在其前面加上代码:
- <?php
- // 此段由WANWAN添加 本页共两段
- $action=$_GET['action'];
- $ariticle_id=$_GET['id'];
- if($action==”load_post”)
- {
- query_posts(“p=$ariticle_id”);
- the_post();
- the_excerpt();
- ?>
- <p><a href=”<?php the_permalink() ?>#more-<? echo $ariticle_id ?>” class=”more-link”>Read more…</a>
- <div class=”fixed”></div>
- <?php }
- else{
- ?>
好了,再到本页最尾部,加入
- <?php } ?>
结束刚才的IF语句..INDEX.PHP搞定.这是最关键一步拉.
第二步,修改INOVE主题中的FOOTER.php文件:
找到
- <?php wp_footer(); ?>
在其后加入:
- <?php
if (is_home() || is_tag() || is_search() || is_month() || is_category() || is_year() ) { ?>
<script type=”text/javascript”>var PRE_LOAD = 2;</script><script type=”text/javascript” src=”/wp-content/themes/inove/js/post.js”></script>
<?php }
?>
好了,第二步完成.
第三步,修改INOVE主题中的style.css文件:
找到
- #notice a
在其后加入
- .post h1 {
display:block;
margin-top:10px;
border-bottom:1px solid #CCC;
padding:0 5px 3px;
font-size:16px;
font-family:Verdana,”BitStream vera Sans”;
}
.post h1 a.toggle,
.post h1 a.expand,
.post h1 a.collapse {
background:url(img/icons.gif) 0 -336px no-repeat;
height:16px;
width:16px;
display:block;
text-indent:-999em;
float:right;
}
.post h1 a.expand {
background-position:0 -320px;
}
.post h1 a.title {
text-decoration:none;
color:#4C4C4C;
}
.post h1 a.title:hover {
color:#2970A6;
}
.post h1 .act a {
font-weight:normal;
}
这步可能有小量问题,不过自己慢慢修改css拉..这不是技术问题了哈.
第四步,继续修改INOVE主题中的index.php文件(丫的,差点忘记了.):
- <div class=”content”>
找到第二个(丫的,注意是第二个)
- <div class=”content”>
看到这个没:
<div class=”content”>
<?php the_content(__(‘Read more…’, ‘inove’)); ?>
<div class=”fixed”></div>
</div>
把之换成:
- <div class=”content”></div>
好了,任务完成.去测试你的首页吧.ENJOY IT!
这里再次感谢mg12 提供如此漂亮美观大方,且耐和谐与GF.W的主题.
关于我提到的,他的<WP-RecentComments发表评论后不手动刷新就不能显示新评论>问题,本人已经找到原因:IIS不支持..用阿帕奇就能免刷新..代码完全不变.错怪mg12 了.表示歉意.真希望他能改进哈.嘿嘿..
各位又啥问题的留言吧.



@Gil
请问你是怎么解决的?我仔细检查了标点之类的各个地方,还是没有效果啊
看来不是INVOVE主题都修改不成功啊
博主如果有时间能帮忙的话,帮帮老兄,这个功能特想要http://www.quietry.com/
@沉寂号
是的。这个内置了一些东西的。你倒是可以剥离。肯定是能行的哈。
@wanwan
恩啦。不能帮你。因为我忙的要死。非常非常。还有,你的博客的评论,在CHROME下不能进行。。。
这个是杯具,现在都开始用CHROME了。要记得兼容啊。我的站全部完全兼容。
站长有功夫帮忙看看呗,真的很需要这个功能
我会一致关注的
请问,为什么我直接访问 http://www.xx.com/?action=load_post&id=123 就回到了我的首页?
而访问您的却是返回ID 123的日志内容?
@冰剑
第一步,修改INOVE主题中的index.php文件:
这步你做到了没?呵呵
@雾寒
你没有设置啊,我去你网站看了的.
用了你的方法,应该操作的都正确,但是图标文件调用不出来,上传你的图标文件后,页面的图标就乱了,有的不显示,那个展开按钮跑到路径前面,求解决办法
@wanwan
明白了,我一开始以为是WP自带有这个方法,原来是自己弄上去的。。
谢谢啦。。
@wanwan
) could you help me? I have read one comment that you have upload http://www.cqnv.net/inove.rar but when I try to download it seems the file have been remove 
hello buddy, I really do not understand how to implement your tip (exactly because I don’t understand chinese
Some help will be appreciated..
regards,
hi, maybe, you can use the Google for anything. i am too busy and have no time to translate this article for you. i just say sorry to you.