WordPress Chinese Forums's Archiver

wietrade 发表于 2008-10-15 18:07

如何从文章中截取固定长度文字在首页显示

由于不能截取固定长度文字,使首页显示非常难看,演示:[url=http://luocanran.cn]http://luocanran.cn[/url]

下边这段是我用的模板代码,里边好像设置了截取长度,但是好像不管用

<div class="featured">
   <h3>Featured Category</h3>
   
    <!--This is where the thumbnails are found for the homepage bottom section - note the custom field name for this image is "thumbnail". Recommended image size is 70x70, as the stylesheet is written for this size.-->
   
    <?php $recent = new WP_Query("cat=4&showposts=2"); while($recent->have_posts()) : $recent->the_post();?>
    <?php if( get_post_meta($post->ID, "thumbnail", true) ): ?>
        <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;" src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" alt="<?php the_title(); ?>" /></a>
    <?php else: ?>
        <a href="<?php the_permalink() ?>" rel="bookmark"><img style="float:left;margin:0px 10px 0px 0px;"  src="<?php bloginfo('template_url'); ?>/images/thumbnail.png" alt="<?php the_title(); ?>" /></a>
    <?php endif; ?>   
    <b><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></b>
    <?php the_content_limit([color=red]80[/color], ""); ?>
   
    <div style="border-bottom:1px dotted #94B1DF; margin-bottom:10px; padding:0px 0px 10px 0px; clear:both;"></div>
   
    <?php endwhile; ?>
    <!--This is where you can specify the archive link for each section. Replace the # with the appropriate URL-->
   
    <b><a href="#" rel="bookmark">Read More Posts From This Category</a></b>
   
   </div>  
还有如何限定那个首页图片显示大小,现在非得自己把图片手工弄成固定大小

口袋 发表于 2008-10-15 20:28

使用more标签把...

toofree 发表于 2008-10-15 22:50

或者用中文工具箱

zern 发表于 2008-10-16 16:41

或者你是个懒人,呵呵用这个插件
    替换文件 index.php等等
   函数the_content()
用这个函数the_content_limit(1000, "more")

t2home 发表于 2008-10-17 01:07

有个en英的插件。。。。。随你定多少字都ok

上面说的中文工具箱我试过,还有一个工具箱的修改版我也试了没效果。。

xxooxxoo 发表于 2008-10-17 22:59

用插件吧,呵呵。

页: [1]

Powered by Discuz! Archiver 7.0.0  © 2001-2009 Comsenz Inc.