« 徐倩SEO优化博客重新登上百度首页对比国内与国外seo/sem公司(转自点石互动) »

wordpress程序建站中摘要设置几种方法

发布:xueshitianqian | 分类:网站运营 | 评论:2 | 引用:0 | 浏览:

最近在使用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>就可以实现了。
 

tagTags:wordpress摘要  
  1. quote 2.zhijiezhang 于 2010-7-13 11:10:30 说:

    谢谢了, 我昨个遇到这个问题, 搜到贵博, 哈哈, 问题解决了, 谢谢了~

    回复该留言

  1. quote 1.天成 于 2010-3-4 21:16:00 说:

    这个有些过期了,貌似其中一部分已经不需要自己改了

    回复该留言

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。