I found this code:
<?php
$args = array(
'orderby' => 'id',
'hide_empty'=> 0,
'child_of' => 2,
'depth' => 5,
);
$categories = get_categories($args);
foreach ($categories as $cat) {
echo '<div>';
echo '<h1>'.$cat->name.'<img src="'.$cat->term_icon.'" alt="" class="alignleft"/>'.'<br />'.'<span class="solutions">'.$cat->description.'</span>'.'</h1>';
//echo '<br />';
$args3= array("orderby"=>'name', "category" => $cat->cat_ID, 'depth' => 5); // Get Post from each Sub-Category
$posts_in_category = get_posts($args3);
foreach($posts_in_category as $current_post) {
echo '<span>';
?>
<li><h1><a href="<?=$current_post->guid;?>"><?=$current_post->post_title;?></a></li></h1>
<?php
echo '</span>';
}
echo '</div>';
}
?>
This lists all categories and posts from a category. But i want it from all categories. But when i fill in 'child_of' => 2
it lists everything, but it does not get formatted well. grandchilds have the same hierarchical status as the children.
what i want for example:
- Parent
- child 1
- grandchild 1
- post 1
- grandchild 2
- post 2
- grandchild 1
- child 2
- post 3
- child 1
so: all cats should be able to handle posts, and if there are only posts in the grandchildren, only list thoseā¦ thanks! -edit- actually it should be the same as wp_list_categories, only i should be able to edit parents, children, grandchildren and post titles separately. (for example, i must be able to remove the href off the child-categories, but not the grandchild-categories..