我已将以下代码放入侧栏。php显示“Store”分类的所有子类别及其帖子的列表。希望我了解你需要什么,这将是有益的。如果没有,可以多问清楚
<?
// Get categories for parent category store
// Get ID cat by slug
$id_store = get_category_id(\'store\');
$stores = get_categories(array(\'child_of\' => $id_store, \'hide_empty\' => 0));
?>
<ul>
<?php foreach ($stores as $categ_list): ?>
<li class="cats-<?php echo $categ_list->cat_ID; ?> dropcats">
<?php echo $categ_list->cat_name; ?>
<?php
$args = array(
\'category\' => $categ_list->cat_ID,
\'numberposts\' => -1,
\'orderby\' => \'title\',
\'order\' => \'asc\'
);
// Get posts for store category
$store_posts = get_posts($args);
// If there is any posts
if (count($store_posts) > 0) {
?>
<ul class="markes">
<?php foreach ($store_posts as $post) { ?>
<li class="post-<?php echo $post->ID; ?>">
<a href="<?php echo $post->post_name; ?>" class="marke-<?php echo $post->ID;?>">
<?php echo $post->post_name; ?>
</a>
</li>
<?php } ?>
</li>
</ul>
<?php }
endforeach;
?>
</ul>
</aside>