• How to make an alphabetical list of category??

    i want someting like what

    list of letter with link A

    A category list

    Art
    Artist
    Arc
    Arm

    B category list
    C category list

    i find this code but is for tags

    <?php
    
         $list = '';
    	$tags = get_terms('post_tag' );
    	$groups = array();
    	if( $tags && is_array( $tags ) ) {
    		foreach( $tags as $tag ) {
    			$first_letter = strtoupper( $tag->name[0] );
    			$groups[ $first_letter ][] = $tag;
    		}
    			if( !empty( $groups ) ) {{
              	$index_row .='<ul class="topindex">';
             foreach ($groups as $letter => $tags) {
               	$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 => $tags ) {
                $list .= '<li><a name="' . $letter . '"></a><h5><a href="#tags_top" title="back to top">' . apply_filters( 'the_title', $letter ) . '</a></h5>';
    				$list .= '<ul class="links">';
    				foreach( $tags as $tag ) {
                   $url = attribute_escape( get_tag_link( $tag->term_id ) );
    					$name = apply_filters( 'the_title', $tag->name );
                   $list .= '<li><a title="' . $name . '" href="' . $url . '">' . $name . '</a></li>';
    
    	} 		 $list .= '</ul></li>';
    			} 	$list .= '</ul>';
    		}
    	}else $list .= '<p>Sorry, but no tags were found</p>';
    
    	?>
    <a name="tags_top"></a>
    <?php print $index_row; ?>
    <?php print $list; ?>

    ul.topindex, .topindex li {display:inline;float:left;padding-right:5px}

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try changing this:

    $tags = get_terms('post_tag' );

    to this:

    $tags = get_terms('category' );
    Thread Starter vl4d

    (@vl4d)

    finaly one reply in my posts @vtxyzzy thank you
    now i want to change this http://prntscr.com/4ir1zk
    is look bad because the code is old and maybe the css is changed anyway

    i want to looks like that
    <center>A B C D I E F H J H S D</center>

    . A
        . Afro Samuray
        . Angel lal
    
     . B
        . bblbaa
        . blablab

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘A-Z index list of category’ is closed to new replies.