2011-03-28 138 views

回答

0

在循环之前声明一些var将保存post类别。比查询与该猫的帖子。

这里是例如:

<?php 
$cat_id = 0; // declare var 
if(have_posts()): 
    while(have_posts()): 
    // do what you usually do 
    $cat_id = $post->post_category; 
    endwhile; 
endif; 

// here you will get posts and make html output 
$last_in_cat = get_posts('posts_per_page=5&cat='.$cat_id); 
foreach($last_in_cat as $cat_post): 
?> 
<a href="<?php $cat_post->guid ?>"><?php $cat_post->post_title ?></a> 
<?php endforeach; ?> 
0

你可以使用WP_Query获得你想要的信息。它非常灵活,你应该开始使用它。 它就像SQL查询一样。

相关问题