DIY个性WordPress首页文章

本文教你让你的首页变得与众不同,既非全文输出所有文章,也非输入文章列表的摘要,而是,输出最新一篇文章的全文或< !–more–>标签之前内容,第二篇以及以后内容输出纯摘要。以两种形式定制首页。其实用今天所说的方法,可以定制几种不同的方式,关键就看你如何设计了。
wordpress

下面是按上图输出文件的方法:
1,打开你的index.php或home.php,找到:
< ?php if (have_posts()) : while (have_posts()) : the_post(); ?>

2,在这一句的前面加上代码:
< ?php $postcnt = 1; ?>

3,然后找到< ?php the_content(); ?>并把它修改为:
< ?php if ($postcnt == 1) : ?>
< ?php the_content(); ?>
// 这里还可以放一个广告,效果很好的位置.
< ?php else : ?>
< ?php the_excerpt(); ?>
< ?php endif; $postcnt++; ?>

上传以后需要到你的wordpress后台设置为输出样式,输出全文则第一篇为全文,输入摘要则显示< !–more–>标签之前内容。< ?php the_excerpt(); ?>是输出去掉html以后的文字的函数,不过对中文不是很友好,建议配合使用Yskin’s wp-CJK-excerpt来解决摘要的问题,也可使用中文WordPress工具箱或其他摘要算法的插件。

这只是首页,同样可以适用到目录页,搜索页等,只需修改相应文件即可。

Comments

20 responses to “DIY个性WordPress首页文章”

  1. […] print? 1.< ?php if (have_posts()) : while (have_posts()) : the_post(); ?> […]

  2. 网络免费基地 Avatar

    这方法不错,谢谢了

  3. 山寨机 Avatar

    不错 谢谢了

  4. bolo Avatar

    嗯,用一个判断循环再加自定义域就行了

  5. iso8999 Avatar

    3Q 正好我全部是全文 正恼火也

  6. rose Avatar
    rose

    如果要前2篇全文显示应该怎么改

    1. aisinvon Avatar

      这篇文章有方法介绍:
      http://twetw.com/1744.html

  7. […] 下面是按上图输出文件的方法: 1,打开你的index.php或home.php,找到: view source […]

  8. springsun Avatar
    springsun

    “上传以后需要到你的wordpress后台设置为输出样式”,到后台设置输出样式?请问怎么设置呀?谢谢回复。

  9. […] print? 1.< ?php if (have_posts()) : while (have_posts()) : the_post(); ?> […]

  10. […] 0 Comment 2009-06-21 1:01 | 来源: 投稿 | 作者: 小饭 | 评论: 9条评论 […]

  11. 华南城网 Avatar

    收藏了,我的wordpress初学。需要大量知识。

  12. hopewind Avatar
    hopewind

    试试,看行不行。

  13. […] DIY个性Wordpress首页文章 « Wopus中文博客平台 – WordPress 1,打开你的index.php或home.php,找到:view sourceprint?1.< ?php if (have_posts()) : while (have_posts()) : the_post(); ?> […]

  14. mofei Avatar

    学习 学习了

  15. […] Wopus有篇文章讲述了如何DIY个性Wordpress首页文章。而碰巧最近我也想把我博客的首页改进一下,以前我的博客就是用的上述方法在首页显示第一篇文章的全文,其余文章摘要或者标题显示。 […]

  16. […] print? 1.< ?php if (have_posts()) : while (have_posts()) : the_post(); ?> […]

  17. […] 下面是按上图输出文件的方法: 1,打开你的index.php或home.php,找到: view source […]

  18. […] 下面是按上图输出文件的方法: 1,打开你的index.php或home.php,找到: view source […]

  19. […] 下面是按上图输出文件的方法: 1,打开你的index.php或home.php,找到: view source […]