首页 » 二次开发 » 阅读文章

wordpress程序建站中摘要设置与内容截取的方法

2010-09-24 09:27 7496 1 发表评论
标签:

最近在使用wordpress做博客网站,开始换模板遇到的问题:

第一:使全部发布的文章显示摘要设置;
通过火狐的插件工具查询到文字区域的class属性,然后再模板文件index.php 中查询class属性对应的位置,将下面的:

<?php the_content( ); ?>替换成下面这句即可。

<?php echo mb_strimwidth(strip_tags(apply_filters(‘the_content’, $post->post_content)), 0, 290,”…”); ?>

第二:在发布文章时候自助选择添加摘要设置:
通过工具查询到文字区域的class属性,然后再模板文件index.php 中查询class属性对应的位置,将下面的:

<?php the_content( ); ?>替换成下面这句即可。<?php the_excerpt();?>

第三种方法:显示更多阅读标签的替换方式:
<?php the_content( ); ?>替换成下面这句即可。

<h2><a href=”<?php the_permalink() ?>” rel=”bookmark”><?php the_title(); ?></a></h2>        <?php the_content(__(‘继续阅读 &raquo;’)); ?>接着替换成下面:

<h2><a href=”<?php the_permalink() ?>” rel=”bookmark”><?php the_title(); ?></a></h2>   <?php echo mb_strimwidth(strip_tags(apply_filters(‘the_content’, $post->post_content)), 0, 600,”…”); ?> <a href=”<?php the_permalink() ?>” rel=”bookmark”>继续阅读 »</a>

第四种列表页加摘要:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>     <li id=”post-<?php the_ID(); ?>”><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php printf(__(‘Permanent Link to %s’, ‘ctn1’), the_title_attribute(‘echo=0’)); ?>”><?php the_title(); ?></a><span><?php the_time(__(‘y-m-d’, ‘ctn1’)) ?></span></li>     

<li>     
<?php echo mb_strimwidth(strip_tags(apply_filters(‘the_content’, $post->post_content)), 0, 290,”…”); ?>
</li>
<?php endwhile; ?>  
   </ul>
以上红色部分是加进去的摘要代码,直接加会出现和标题在同一行上,我们就加了换行标签<li></li>就可以实现了。

本文地址:http://www.jwzzsw.com/archives/339.html

文章作者:思悟
版权所有 © 转载时请以链接形式注明作者和原始出处!

评论 共1条 (RSS 2.0) 发表评论

  1. 气体预处理说道:

    不错不错!
    别忧郁

发表评论

联系我 Contact Me

回到页首