在WordPress首页显示摘要的方法

 将模版index.php中<?php the_content(); ?> 换用这个语句
($post->post_excerpt != “”)? the_excerpt() : the_content();
来选择输出摘要还是全文。

注释:如果全文摘要非空输出摘要,若空输出全文。

还可以加上

<p ><?php if ($post->post_excerpt != “”) { ?><a href=”<?php the_permalink() ?>” >阅读全文</a><?php } ?>

我在月光blog看了他的文章在WordPress首页和目录页显示摘要的方法也想在本Blog实现,可惜未成功,出现乱码。
查找资料 the_excerpt()是输出摘要的函数,the_content()是输出全文的。

我仅用the_excerpt()还是在有的文章出现混乱。于是查找资料 选择输出。

定义the_excerpt_reloaded()的插件本Blog未装,所以无法使用。

另附上月光的方法

<?php if (function_exists(‘the_excerpt_reloaded’)) { ?>
 <?php the_excerpt_reloaded(120, ‘<p><a><ul><ol><li><img><br /><blockquote><em><strong><div>’, ‘content’, FALSE, ”, FALSE, 1, TRUE); ?>
 <?php } else { ?>
 <?php the_excerpt(); ?>
 <?php } ?>
 <div class=”details”><div class=”inside”><?php comments_popup_link(‘No Comments’, ‘1 Comment’, ‘% Comments’); ?> so far | <a href=”<?php the_permalink() ?>”>Read On »</a></div></div>

作者: itofly

itofly I to Fly

《在WordPress首页显示摘要的方法》有一个想法

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据