在两行/两列中仅显示一个类别中的内容



如何从一个类别中只显示某些条目我想有两列,其中两组条目都来自不同的类别,我还试图让其中一列显示10篇帖子,其他5篇有想法吗?。

这是我当前的代码:

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div id="art-av">
<div id="av-side-l">
<div id="av"><?php if ( has_post_thumbnail() ) { /* loades the post's featured thumbnail, requires Wordpress 3.0+ */ echo '<div class="featured-thumbnail">'; the_post_thumbnail(); echo '</div>'; } ?>
</div>
<div id="date-av"><?php the_time('F j, Y'); ?></div>
<div id="com-av"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></div>
</div>
<div id="av-side-r">
<div id="tit-av"><a href="<?php the_permalink() ?>" class="blue" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></div>
<div id="dec-av">
<?php the_excerpt(); ?>
</div>
</div>
</div>
<?php endwhile; ?>

http://codex.wordpress.org/Template_Tags/get_posts

$args = array(
    'numberposts' => [5 or 10],
    'category' => [name, slug, whatever]
);
$posts = get_posts()
foreach($posts as $post){
    setup_postdata($post);
    // the rest of your code here
}

最新更新