我目前正在使用以下代码来获取类别页面中的子类别,并获取每个子类别的帖子。在回显“span-12”(第14行)的部分,我希望它对其他子类别回显“span-12 last”。
我的代码:
<?php $cats = get_categories(\'child_of=\'.get_query_var(\'cat\'));
foreach ($cats as $cat) :
$args = array(
\'orderby\' => \'title\',
\'order\' => \'ASC\',
\'posts_per_page\' => -1, // max number of post per category
\'category__in\' => array($cat->term_id)
);
$my_query = new WP_Query($args);
if ($my_query->have_posts()) :
echo \'<div id = "seasonBlock" class = "span-12" >\';
echo \'</br><h3 class = "seasonTitle" >\'.$cat->name.\'</h3>\';
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php /*general loop output; for instance: */ ?>
<div id = "episodeBlock" >
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
aired <?php if(!function_exists(\'how_long_ago\')){the_time(\'F jS, Y\'); } else { echo how_long_ago(get_the_time(\'U\')); } ?><br />
</div>
<?php endwhile; ?>
</div>
<?php else :
echo \'No Posts for \'.$cat->name;
endif;
wp_reset_query();
endforeach; ?>
在本部分中,(第14行) echo \'<div id = "seasonBlock" class = "span-12" >\';
我想对每个其他类别进行回应,我希望它像这样回应 echo \'<div id = "seasonBlock" class = "span-12 last" >\';
我找到了一些用于添加和检查是否奇怪的代码,但这似乎不适用于此代码。