我们在WordPress CMS网站中常常看到同一分类调用不同的文章样式,前面几篇和后面的文章显示不同的样式
通过以下代码即可实现这个功能:
area data-settings="dblclick" readonly ><?php query_posts("showposts=2&cat=1"); ?><?php while (have_posts()) : the_post(); ?> <div > <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 ><?php query_posts("showposts=3&cat=1&offset=2"); ?><?php while (have_posts()) : the_post(); ?><li><span > <a href="<?php the_permalink() ?>" targent="_blank" ><?php the_title_attribute(); ?></a> </span></li><?php endwhile; ?>area>12345678910111213<?php query_posts("showposts=2&cat=1"); ?><?php while (have_posts()) : the_post(); ?><div > <a href="<?php the_permal
ink() ?>"><img src='<?php echo catch_first_image() ?>' border='0' width='120' height='90' alt='<?php the_title_attribute(); ?>'></a><h4><a href="<?php the_permal
ink() ?>"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 ><?php query_posts("showposts=3&cat=1&offset=2"); ?><?php while (have_posts()) : the_post(); ?><li><span > <a href="<?php the_permal
ink() ?>" targent="_blank" ><?php the_title_attribute(); ?></a> </span></li><?php endwhile; ?>
以上代码是调用分类id为1的列表
前面两篇文章是上面图片展示的样式,之后的文章以列表的形式显示!