I am using this code. Now i want to add “…” at the end of every category titles with more than 10 characters.’
sample: coconut is the b…
how to do that?
<a href="' . get_category_link($category->term_id) . '">' . substr($category->cat_name, 0, 10) . ' </a>
You can check the string length first to see that the string is larger than 10 characters:
Here is the manual for
strlen()
: http://php.net/manual/en/function.strlen.phpWill do this. Set your output without substr() after this if statement, you can keep $category->cat_name as object
You can use this function:
Hope this will help you.