查看文章

显示摘要的郁闷


Warning: Invalid argument supplied for foreach() in /home/www/blog/wp-content/plugins/where-did-they-go-from-here/where-did-they-go-from-here.php on line 54

郁闷,摘要显示的话怎么在首页显示图片呢?

显示摘要的代码为:<?php the_excerpt(); ?>
显示全文的代码为:<?php the_content(); ?> (此处可能在括号里加上类似”Continue reading ‘” . the_title(”, ”, false) . “‘”的内容,目的是在日志内加上“<!–more–>”标签时显示Continue reading 的链接)

这样我们就明白了如何修改自己的模板,让它在何时显示全文或者摘要。

举例:想在首页和存档时不显示全文,而显示日志摘要,则在index.php和archive.php里查找“<?php the_content…”,把这行语句替换为“<?php the_excerpt(); ?>”即可。

如果模板调用的只是一个Loop语句,这时修改就要费些功夫了,下面的代码作用为只在单篇日志时显示全文,其它页面则显示摘要:

<?php if ( is_single()  ) { ?>   <?php the_content(”Continue reading ‘” . the_title(”, ”, false) . “‘”); ?>      <?php } else { ?>       <?php the_excerpt(); ?>      <?php } ?>

Popularity: 3% [?]

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • No Related Post

2 Responses to “显示摘要的郁闷”

  1. minidxer says:

    把图片加在前面部分就可以显示了阿

  2. admin says:

    加前面也没有用啊

Post a Comment