• Hi all,

    I’m having some troubles with what would appears to be a simple idea. I’m trying to:

    1. Output a list of child categories to the depth of 1
    2. Customise that list

    I have chosen to use get_categories due to my lack PHP skill in creating a custom walker for wp_list_categories. As I understand it I should simply able to pass ‘parent’ => cat_ID as an argument into get_categories for it to return child (1 level below the parent).

    I’m finding that when using parent I get no output, but if I use child_of I get all children and grand-child.

    <ul id="find-it" class="group">
    
                   		<?php $args = array('child_of' => 922); ?>
                    	<?php
    							$categories = get_categories($args);
    					  		foreach($categories as $category) {
    
    							echo'<li>
    
    									<a id="'. $category->slug .'" href="">' . $category->name . '
    
    										<span>'. $category->description .'</span>
    
    									</a>'; ?>
    
    									<img src="<?php bloginfo('template_directory'); ?>/assets/graphics/category-image/<?php echo $category->slug ?>.jpg" />
    
    								  <?php echo '</li>'
    
    							;}
    					 ?>
    
                    </ul>

    The live page can be found here and is currently using child_of to demonstrate the layout.

    Can anyone explain why parent isn’t working/what I’m doing wrong?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘get_categories 'parent' parameter not working’ is closed to new replies.