Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $chars_limit = 5;
- $sep = '';
- foreach((get_the_category()) as $cat) {
- $chars_text = strlen ($cat->cat_name);
- $cat_short = substr ($cat->cat_name, 0, $chars_limit);
- if ($chars_limit < $chars_text) {
- $cat_short = $cat_short . "...";
- }
- echo $sep . '<a href="' . get_category_link( $cat->term_id ) . '">' . $cat_short . '</a>';
- $sep = ', '; //comma separated list
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement