$20
Parent Category Page - List child categories excerpts
I am not fantastic at describing what I need, but here goes :)
This is using category.php file.
When clicking a top-level category page link on my menu I want category.php to display child and grand children category headers along with 5 titles and excerpts of each child and grand children category in that top-level category but no top-level category posts.
So if someone clicks a menu item that is a top level category it displays each child and grand child category header, 5 titles & excerpts but I do not want to show posts from the top level category (I really want the top level to act as a gateway to it's children & grand children.)
Then when someone clicks either a category header from one of the child or grand child categories it takes them to a page listing all posts from that child or grand child category (showing something like this - http://paste-it.net/public/j635f6b/). That paste-it is my current category.php which displays posts from any category (top-level, child & grand child) when a category menu link is clicked.
Can anyone make sense of my nonsense and help?
Look forward to hearing from you.
All the best,
Karl
Karl | 04/08/10 at 1:55pm
| Edit
(1) Possible Answers Submitted...
Note: Karl felt their question was unanswered, so we granted them a refund.
Note: Karl requested a refund. They offered no explanation.
-

Last edited:
04/08/10
2:19pmErez S says:so you don't want the category page to show posts from the category itself,but only from it's child category and grand children category?
fix me if i'm wrong- 04/08/10 2:28pm
Karl says:Yes that is correct. Essentially, when a user clicks on ,say, Arts & Entertainment they are shown a page that shows - for example - music, arts, theatre child cats with post excerpts. Like this mock-up I did: http://tinypic.com/view.php?pic=10ogrr8&s=5
then when they click child cat it takes them to my current category.php as per my paste-it code. - 04/08/10 2:40pm
Erez S says:replace line 49:
<?php $b = 1; $query2 = new WP_Query();$query2->query('posts_per_page=5&cat=' . get_query_var('cat')); ?>
with this:
<?php
$category = get_the_category();
$cat_id = $category[0]->cat_ID;
$args=array(
'child_of' => $cat_id,
'type' => 'post'
);
$categories=get_categories($args);
$str = '';
foreach($categories as $category) {
$str .= $category->term_id.',';
}
$str = substr($str, 0, -1);
$b = 1; $query2 = new WP_Query();$query2->query('posts_per_page=5&cat=' . $str);
?>
enjoy - 04/08/10 2:59pm
Karl says:Thanks for that but that is not quite what I am after. The image I attached is what I want or my category landing page. the code I posted is what I want to use for a gateway from category.php.
basically I just want to display child & grand child categories on category.php showing 5 posts from each child/grand of top level category.
Thanks anyway - 04/08/10 3:11pm
Erez S says:the code i gave you is showing only child category's posts and grand children's posts on the category page,what is the problem?
- 04/08/10 3:27pm
Karl says:Hi erez213,
Sorry, not great at explaining.
I think you based your code to work on my slider but I need to show each child/grand independently of each other like my image shows. Can that be done?
Please ignore the category.php I posted. Can you create a category.php just based on your code but like I want in my image? ie. category, title excerpt then the next 3 titles but for each child of top-level category.
Thank you - 04/08/10 3:32pm
Erez S says:ok,now i get it,but i have to go to sleep,if nobody will do it to you intil tommorow i will do it
- 04/08/10 3:35pm
Karl says:Thank you erez213,
I wish I was more articulate when it comes to explaining what I need in code.
Thanks for your patience. - 04/08/10 4:59pm
Karl says:Not sure if this is of any help, but this is the code I use to create a box on my homepage. You may be able to convert this to work dynamically with child / grand cats.
http://paste-it.net/public/u587351/
One of these creates as 1 box like in this image: - 04/09/10 1:17pm
Karl says:Hi erez213,
I wondered if you were able to help further?
Thanks
- 04/08/10 2:28pm
This question has expired.
Current status of this question: Refunded





