vino
vino

Reputation: 302

How to show wordpress parent catgorie page show subcategories list

It's possible parent categories show subcategories list (name,image,description)

Example

Parent Category:

Thanks

Upvotes: 1

Views: 624

Answers (2)

vino
vino

Reputation: 302

I have solved this. Please find the code given below,

<?php $this_category = get_category($cat); ?>   

<ul class="product_list">
    <?php
    $id = get_query_var('cat');
    $args = array(  'parent' => $id );
    foreach (get_categories($args) as $cat) : ?>

    <li>
        <a href="<?php echo get_category_link($cat->term_id); ?>"><img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" /></a>
        <a href="<?php echo get_category_link($cat->term_id); ?>"><?php echo $cat->cat_name; ?></a>
        <p><?php echo $cat->description; ?></p>

    </li>

    <?php endforeach; ?>
</ul>

Thanks,
Vino

Upvotes: 3

Anjana
Anjana

Reputation: 499

Yes

<?php wp_list_categories('child_of=parent_cat_id'); ?>

Referance This

Upvotes: 1

Related Questions