I'd like to list my categories in a loop from a-z, the code i currently have just keeps repeating over and over im not sure what the problem is but the format should look something like.
Parent Category
- Child Category
- Child Category
- Child Category
- Child Category
My code:
<?php
$args = array( 'orderby' => 'name','order' => 'ASC' );
$categories = get_categories( $args );
foreach($categories as $category) {
echo '<p><a href="'.get_category_link( $category->term_id ).'">'.$category->category_nicename.'</a></p>';
echo '<p class="cat-child"><a href="'.get_category_link( $category->term_id ).'">'.$category->child.'</a></p>';
}
?>
get_categories
would probably be more suitable for your use.