Advertisement
vjpo

my_cat_list

Aug 22nd, 2011
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Custom snippet based on WordPress get_the_category() function.
  4.  * Gives unique CSS class name to each category link
  5.  * like class="cat-item-1" where 1 is a category ID number.
  6.  * Add function to functions.php file.
  7.  * Place <?php my_cat_list(); ?> to wp loop.
  8. **/
  9.  
  10. function my_cat_list() {
  11.     $sep = '';
  12.     foreach((get_the_category()) as $category) {
  13.     echo $sep . '<a href="' . get_category_link( $category->term_id ) . '" class="cat-item-' . $category->cat_ID . '" title="View all posts in ' . $category->cat_name . '" >' . $category->name. '</a>';
  14.         $sep = ', ';
  15.     }
  16. }
  17. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement