Advertisement
Guest User

Untitled

a guest
Jan 4th, 2018
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. function colormag_colored_category() {
  2. global $post;
  3. $categories = get_the_category();
  4. $separator = ' ';
  5. $output = '';
  6. if ( $categories ) {
  7. $output .= '<div class="above-entry-meta"><span class="cat-links">';
  8. foreach ( $categories as $category ) {
  9. $color_code = colormag_category_color( get_cat_id( $category->cat_name ) );
  10. if ( ! empty( $color_code ) ) {
  11. $output .= '<a href="' . get_category_link( $category->term_id ) . '" style="background:' . colormag_category_color( get_cat_id( $category->cat_name ) ) . '" rel="category tag">' . $category->cat_name . '</a>' . $separator;
  12. } else {
  13. $output .= '<a href="' . get_category_link( $category->term_id ) . '" rel="category tag">' . $category->cat_name . '</a>' . $separator;
  14. }
  15. }
  16. $output .= '</span></div>';
  17. echo trim( $output, $separator );
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement