如何从一个类别中仅显示某些条目我想要有两个列,其中两个条目来自不同的类别,我也试图让一个显示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; ?>
答案 0 :(得分:0)
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
}