阿里云服务器

 我们在WordPress CMS网站中常常看到同一分类调用不同的文章样式,前面几篇和后面的文章显示不同的样式。

3422.JPG

通过以下代码即可实现这个功能:

<?php query_posts("showposts=2&cat=1"); ?>
<?php while (have_posts()) : the_post(); ?>
      <div class="category-item-top"> <a href="<?php the_permalink() ?>"><img src='<?php echo catch_first_image() ?>' border='0' width='120' height='90' alt='<?php the_title_attribute(); ?>'></a>
        <h4><a href="<?php the_permalink() ?>"  target="_blank"><?php the_title_attribute(); ?></a></h4>
        <p><?php echo mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 80,"..."); ?></p>
 </div>
<?php endwhile; ?>

      <ul class="indexList1">
<?php query_posts("showposts=3&cat=1&offset=2"); ?>
<?php while (have_posts()) : the_post(); ?>
        <li><span class="articletitle"> <a href="<?php the_permalink() ?>" targent="_blank" style="color:#F81F5A;"><?php the_title_attribute(); ?></a> </span></li>
<?php endwhile; ?>

以上代码是调用分类id为1的列表

前面两篇文章是上面图片展示的样式,之后的文章以列表的形式显示!

相关阅读:
  • wordpress搜索功能优化:只搜索指定分类的文章
  • WordPress调用指定分类子分类的数据和文章列表
  • WordPress无用数据清理插件:WPDBSpringClear
  • 设置WordPress一级分类不显示二级分类文章的方法
  • wordpress下拉菜单设置方法
  • WordPress页面添加自定义摘要功能
  • wordpress文章页调用当前分类名和链接的方法
  • wordpress特色图片地址调用方法
  • WordPress分别循环输出多个分类的最新文章