Advertisement
Viper007Bond

Untitled

Jul 19th, 2011
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. <?php
  2.  
  3. $books = get_terms( 'book_titles', array( 'orderby' => 'name' ) );
  4.  
  5. $previous_letter = false;
  6.  
  7. foreach ( $books as $book ) {
  8.  
  9.     // If the first letter is not the same as the previous book,
  10.     // then start a new section.
  11.     $letter = substr( $book->slug, 0, 1 );
  12.     if ( $previous_letter != $letter ) {
  13.         $previous_letter = $letter;
  14.  
  15.         echo "Here's all of the letter " . strtoupper( $letter ) . ' books:<br />';
  16.     }
  17.  
  18.     echo '<a href="' . esc_url( get_term_link( $book ) ) . '">' . esc_html( $book->name ) . '</a><br />';
  19. }
  20.  
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement