我有个问题。我想在我的主页(模板)上显示5个类别的最后帖子作为摘录。指摘自cat的最后一篇文章。1,cat的最后一篇文章。以此类推,我得到了5篇文章(摘录),每一篇都来自不同的类别,即cat。1-5。;
我怎样才能做到“简单”?
编辑:我这样做了:
<?php
$args = array( \'posts_per_page\' => 1, \'order\'=> \'DESC\', \'orderby\' => \'post_date\', \'category\' => \'5\', );
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post); ?>
<ul class="recent-posts-2">
<div class="cat"><a href="<?php echo get_page_link(149); ?>">my 1. category</a></div>
<li><h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2></li>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(array( 120,120 ), array( \'class\' => \'recent-thumbs\' )); ?></a>
</ul>
<?php endforeach; ?>
<?php
$args = array( \'posts_per_page\' => 1, \'order\'=> \'DESC\', \'orderby\' => \'post_date\', \'category\' => \'7\', );
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post); ?>
<ul class="recent-posts-2">
<div class="cat"><a href="<?php echo get_page_link(151); ?>">my 2. category</a></div>
<li><h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2></li>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(array( 120,120 ), array( \'class\' => \'recent-thumbs\' )); ?></a>
</ul>
<?php endforeach; ?>
Dis示例显示了2只猫的2个摘录,我必须重复它,直到我得到我的5篇文章。我想,也许有更好的办法。谢谢,也很抱歉我的“很棒”英语,-奥威尔