Category overview page with comment counts
-
Hi,
Ive been trying to get a page that lists:
- all child categories from a certain category ID
- per child category the category description
- per child category the amount of posts in it
- per child category the last 2 posts below the description
- per child category the last post date
- per child category the amount of comments on the posts in that category
That last one is giving me a hard time… can’t get it to work.
Here is the code I use… could use some fresh eyes.
(don’t mind syntax please clean up is needed).<?php $categories = get_categories('child_of=225'); foreach ($categories as $category) { //Display the sub category information using $category values like $category->cat_name echo '<div class="row clearfix">'; echo '<div class="col1"><div class="inner"><h2>'.$category->name.'</h2>'; echo '<p>'.$category->description.'</p>'; echo '<p class="recent"><strong>Meest recent:</strong></p>'; echo '<ul class="recentlist">'; foreach (get_posts('posts_per_page=2&cat='.$category->term_id) as $post) { setup_postdata( $post ); $my_date = mysql2date("D j M Y - H:i", $post->post_date); echo ' <li><a>ID).'">'.get_the_title().'</a></li> '; } echo ''; echo '</div></div>'; //end .col1 .inner echo '<div class="col2">'.$category->count.'</div>'; echo '<div class="col3">COMMENT COUNT MAGIC MUST TAKE PLACE</div>'; //comment count here! echo '<div class="col4">'.$my_date.'</div></div>'; } ?>
And a screenshot to visualise the stuff.
Cheers,
Paul
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Category overview page with comment counts’ is closed to new replies.