Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Custom snippet based on WordPress get_the_category() function.
- * Gives unique CSS class name to each category link
- * like class="cat-item-1" where 1 is a category ID number.
- * Add function to functions.php file.
- * Place <?php my_cat_list(); ?> to wp loop.
- **/
- function my_cat_list() {
- $sep = '';
- foreach((get_the_category()) as $category) {
- 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>';
- $sep = ', ';
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement