如何显示子类别仅上次更新的帖子?

时间:2012-03-28 09:52:42

标签: php wordpress

我有类别列表,如

Designtype

Multi
    Sub cat multi 1
    sub cat multi 2
Borring
    Jall
    Daman
    Dupatta
    top parsi
Sequence
Trapping

我想显示jall damna dupatta和top parsi的最后一篇文章

1 个答案:

答案 0 :(得分:0)

<?php

$cat = get_categories();
echo “<pre>”;
//print_r($cat);
for each ($cat as $c)
{
if($c->cat_name == “Boring”)
{

$sub_cat = $c->term_id;
$cat2 = get_categories();

for each ($cat2 as $c2)
{

if($c2->parent == $sub_cat)
 {

echo “<pre>”;
echo $c2->cat_name;
echo “<br/>”;
 $aaaaaaaaaaaaaa =  query_posts(array(‘category_name’ => $c2->cat_name, ‘posts_per_page’ => 1 ));
print_r($aaaaaaaaaaaaaa);

} } } }

&GT;