A to Z list of Categories

Trying to create an A to Z index list of categories on a WP page. I’ve achieved this for the tags using this code:

            <ul class="index-p clearfix">
            <h3>A</h3>
                <?php
                $tags = get_tags( array('name__like' => "a", 'order' => 'ASC') );
                foreach ( (array) $tags as $tag ) { ?>
                <li>
                    <a href="<?php echo get_tag_link( $tag->term_id ) ?>">
                        <img src="<?php echo get_option('home'); ?>/wp-content/thumbs/<?php echo $tag->slug; ?>-small.jpg" alt="<?php echo $tag->name ?>" />
                        <span class="info">
                            <span class="name"><?php echo $tag->name ?></span>
                            <span class="number"><?php echo $tag->count ?> Clips</span>
                        </span>
                    </a>
                </li>
                <?php } ?>
            </ul>

The above code will list all tags starting with the letter A. Is there a piece of code similar too the above to achieve the same thing for category’s.

Read More

Thanks

Related posts

Leave a Reply

2 comments