I want to limit the character count of automatically generated page titles in php.
Can you come up with any php or jquery code that can do this for me, with me just entering the character count maximum I want in page titles (70 characters)?
I want to limit the character count of automatically generated page titles in php.
Can you come up with any php or jquery code that can do this for me, with me just entering the character count maximum I want in page titles (70 characters)?
The previous answers were good, but please use multibyte substring:
Otherwise multibyte characters could be splitted.
usage:
This is what substr is often used for.
What about something like this?
You can use this simple truncate() function:
For example, in your template files/wherever you enter the title tag: