truncate first post title
-
Hi
I’m using the following code to truncate the titles on the blog page:function max_title_length( $title ) { $max = 18; if (strlen( $title ) > $max && get_post_type() == 'post') { return substr( $title, 0, $max ). " …"; } else { return $title; }} add_filter( 'max_title_length', 'title' );
(edit) I’ve found an alternative with CSS so you won’t see it happening on the site but I’d like to find the answer if I can as I’m trying to get better at PHP
It’s working but not on the first title. Do I need to add something else?
- This topic was modified 4 years, 6 months ago by .
- This topic was modified 4 years, 6 months ago by .
The page I need help with: [log in to see the link]
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘truncate first post title’ is closed to new replies.