Get the children of the parent category

Question

I’m trying to get all the children categories to display in this loop but I’m struggling with the code. This is what I have so far.

<?php $args=array('orderby' => 'name', 'order' => 'ASC');
    $categories=get_categories($args); 
    foreach ($categories as $cat) { ?>
    <dt><a href="#" class="customer-acquisitiontop" id="<?php echo $cat->slug; ?>" data-filter=".<?php echo $cat->slug; ?>"><h2><?= $cat->cat_name; ?></h2></a></dt>
    <dd><div class="services">
    <?= $categories=get_categories('parent'); ?> /*This should be the children of the parent category */
    </div>
    </dd>
<?php } ?>

Any help would be great

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/get-the-children-of-the-parent-category/">

Get the children of the parent category</a>
0
, , , Chris Da Sie 8 years 0 Answers 56 views 0

Leave an answer