分类
WordPress代码片断

wordpress有摘要显示摘要没摘要截取一段正文内容

<?php if (has_excerpt()) {
                echo $description = get_the_excerpt();
            }else {
                echo mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 200,"……"); 
            } ?>
分类
WordPress代码片断

wordpress 调用第一篇文章 不同样式

<?php
  $count = 1;
  $display_categories = array(1);
  foreach ($display_categories as $category) { 
?>
            <?php query_posts("showposts=5&cat=$category")?>
            <?php while (have_posts()) :the_post(); ?>
            <?php if($count==1){ ?>
                <li class="">
                    <div>
                     <small class=""><?php the_time('Y-m-d') ?></small>
                    <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
                    </div>
                    <p class=""><?php echo mb_strimwidth(strip_tags(apply_filters('the_content',
$post->post_content)), 0, 200,"……"); ?></p>
                </li>
            <?php }else{ ?>
            <li class="">
                <small class=""><?php the_time('Y-m-d') ?></small>
                <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php echo
            mb_strimwidth(get_the_title(), 0, 80, '…'); ?></a>
            </li>  
            <?php } $count++;endwhile; ?>
            <?php } wp_reset_query();?>