• hi…
    i want to have a page that says..

    A
    Archives
    Assists

    B
    Bike
    Booze
    Brand

    C…. etc…

    all those name are categories…i like to have a starting capital letter before the list.. and list all the categories with that starting letter..

    im not sure if theres a plugin that does that..
    basically i want to have a rolodex on my page..

Viewing 2 replies - 1 through 2 (of 2 total)
  • I think you can modify the code here:
    http://wordpress.org/support/topic/288774

    need to change:

    $tags = get_terms( 'post_tag' );

    to

    $tags = get_terms( 'category' );

    Here’s the code to display categories alphabetically in a list with clickable anchor links:

    <?php
    
    				$list = '';
    				$cats = get_terms('category');
    				$groups = array();
    				if( $cats && is_array( $cats ) ) {
    					foreach( $cats as $cat ) {
    						$first_letter = strtoupper( $cat->name[0] );
    						$groups[ $first_letter ][] = $cat;
    					}
    						if( !empty( $groups ) ) {{
    						$index_row .='<ul class="topindex">';
    					 foreach ($groups as $letter => $cats) {
    						$index_row .= '<li><h4><a href="#' . $letter . '" title="' . $letter . '">' . apply_filters( 'the_title', $letter ) . '</a></h4></li>';
    					}
    							$index_row .='</ul><br class="clear" />';} 
    
    							 $list .= '<ul class="index">';
    						 foreach( $groups as $letter => $cats ) {
    						$list .= '<li><a name="' . $letter . '"></a><h5><a href="#cats_top" title="back to top">' . apply_filters( 'the_title', $letter ) . '</a></h5>';
    							$list .= '<ul class="links">';
    							foreach( $cats as $cat ) {
    						   $url = attribute_escape( get_category_link( $cat->term_id ) );
    								$name = apply_filters( 'the_title', $cat->name );
    						   $list .= '<li><a title="' . $name . '" href="' . $url . '">' . $name . '</a></li>';
    
    				} 		 $list .= '</ul></li>';
    						} 	$list .= '</ul>';
    					}
    				}else $list .= '<p>Sorry, but no cats were found</p>';
    
    				?>
    			<a name="cats_top"></a>
    			<?php print $index_row; ?>
    			<?php print $list; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘show category with sort alphabetical title’ is closed to new replies.