Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Anybody could help me to make a category page only. Thank you.

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

You'll want to stick something like this in your theme's category.php file:

<?php
// fetch the categories with the parent being the current cat
$sub_cats = get_terms('category', array(
    'parent' => get_queried_object_id()
));
if(!is_wp_error($sub_cats) && $sub_cats)
{
    foreach($sub_cats as $cat)
    {
        // Create your grid here, this is just an example
        printf(
            '<a href="%s">%s</a>',
            get_term_link($cat, $cat->taxonomy),
            $cat->name
        );
    }
}
share|improve this answer
    
Thanks Davis. But This just fetch 2 of sub category. For example: cat: cat1, cat2 but cat has 5 sub category (cat1, cat2,...,cat5). Whats wrong? And after user take cat1, that code can not fetch again the sub category [cat1: sub_cat1, sub_cat2,...,sub_cat4]. How make this? Thank you. :) –  Juan Lie Jul 6 '12 at 2:47
    
Do those other subcategories have posts in them? –  chrisguitarguy Jul 6 '12 at 2:59
    
yes, for example: cat: apple cat1: red apple, cat2: green apple, ..., cat5: blue apple, and sub_cat1: small red apple, ..., sub_cat3: big red apple. cat -cat1 --sub_cat1 --sub_cat2 --sub_cat3 -cat2 etc thank you –  Juan Lie Jul 6 '12 at 3:28
    
yeah, Solved... give more argument because any category is null 'hide_empty' => 0 thx –  Juan Lie Jul 6 '12 at 6:00
add comment

This may be something you are looking for:

http://wordpress.org/support/topic/how-to-display-the-child-category-of-a-specific-parent-category

Which would be something along these lines:

$args = array( 'cat' => yourcatid, 'post_parent' => $post->ID, 'number_of_posts' => -1 );

$posts = get_posts($args);

foreach($posts as $post)
{
?>
    <a href="<?php echo get_permalink($post->ID); ?>">
    <?php echo $post->the_title; ?>
    </a>
    <p><?php echo $post->the_excerpt; ?></p>
<?php } ?>

This would go into the template you use for the the sub-category

share|improve this answer
    
nothing happened of your solution. Please see the answer above. But little problem occurred. Maybe you've solution. thank you –  Juan Lie Jul 6 '12 at 3:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.