first add this function to your functions.php file
function max_title_length($title){
$max = 20;
return substr( $title, 0, $max ). " …";
}
then before the loop of the code you linked add this line to hook the above function:
add_filter( 'the_title', 'max_title_length');
and after the loop remove this filter:
remove_filter( 'the_title', 'max_title_length');
and just change $max = 20;
to whatever you want.
Related Posts:
- Elasticsearch: Max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
- Changing the username character limit from four to less characters
- WordPress User Name Limitations
- apply_filters/do_action tag characters limit
- limit characters when posting from form
- How do I shorten the title lenghs with Elementor theme? [closed]
- register_post_type name character limit
- Is there a maximum limit of the number of users returns by WP_User_Query?
- Adding character count and limit in comments, modifying labels and fields – jetpack
- Show ellipsis (…) only if the number of characters exceeds limit defined in substr
- Fixed height of the_content()
- Limit username to specific characters (A-Z and 0-9)
- Truncating characters in Advanced Custom Fields works some places but not others?
- MySQL – UPDATE query with LIMIT
- How to fix the “508 Resource Limit is reached” error in WordPress?
- If a hacker changed the blog_charset to UTF-7 does that make WordPress vulnerable to further attacks?
- Remove more or […] text from short post
- Strange characters – despite everything being UTF-8
- Decrease file size upload in Media
- excerpt in characters
- How can I limit the number of comments per registered user per day?
- (un)wptexturize() — is it possible?
- Ability to set character limit in BuddyPress?
- Special characters in WordPress UTF-8 [closed]
- How to limit user to publish post per day and per role?
- Restrict users from editing post based on the age of the post
- Divide Post content into separate divs for every 500 characters (or any other character counts)
- Limit the_excerpt with max of x characters
- Set minimum number of characters in the search
- Allowed memory size exhausted. WordPress side solution
- Remove empty lines ( ) when author updates their post
- dynamically limit depth of wp_list_pages
- Is there a limit on the number of attachments?
- WordPress turns HTML code to HTML entities
- Search and replace special characters (å,ä,ö) for image attachments only in database
- WordPress Defined Memory Limit
- Limiting the number of posts in WP_Query leads to unexpected result
- How do I remove weird characters in text?
- Plugin To Insert Chinese Characters in Posts or Pages
- Limit amout of sessions on user-by-user basis?
- How to limit post of custom post status?
- How to only show posts assigned to current user, only in certain post types
- Hebrew Characters Have gone bad
- Limit Number of Taxonomy Terms (Images) Displayed
- Limit posts per author role (excluding admin) in home page
- How to limit comment author to one comment per post
- Problem loading custom post type admin page
- Get latest 3 posts from multiple CPT in one query
- How can i preserve wordpress database encoding after using wp-cli search-replace with –export flag?
- How to limit posts by category
- Pages views limit [closed]
- Limit post creation by role
- Is there any way to use google input tool or any other language keyboard with WordPress [closed]
- How can i limit the number of posts created per category?
- Limit 1 global comment per minute
- WordPress Media Library – Upload space used
- Migrated WordPress site renders Chinese
- Limiting number of related posts
- return only the first two terms of custom post
- how to avoid the character conversion of WordPress pages?
- Defined WordPress Memory Limit to Unlimited
- How can I allow Arabic usernames in WordPress
- Preg_Match(): compilation failed unknown property name
- How to solve Woocommerce Memory Limit
- Limit blogs creation
- Check & remove special characters in a field?
- Set different max upload size limits based on file type/extension
- Single Time Login HELP
- Greek characters only showing in certain circumstances
- Ampersand breaking Widget title
- Restrict characters in comment section
- Icons (non-Latin symbols) displaying incorrectly
- What’s the Max character limit for a post in WordPress?
- How to get rid of Ellipsis on Woocommerce [Essential] Theme [closed]
- Toggle Shortcode Sanitize Title
- Limit Loop to One Category
- Setting limit to posts or page creation
- Invalid characters in user name when registered
- Problem with revisions only returning four results
- Search results doesn’t show with Turkish characters
- After migration, all featured images using accentued characters in their file names are displayed “blanked”
- Character encoding issue – black diamond question marks on imported post excerpts
- How to write in MySQL more characters in user_nicename
- WP website won’t accept any new content – need dedicated hosting?
- Balance Tags to the_content Words Length
- How to restrict type/size of file uploads in any plugin?
- WordPress character set issue
- Video limit about wordpress
- Is there a way to limit multi upload in media upload box?
- Limit attachment caption characters
- Why is converting my database to UTF-8 truncating entries?
- How to prevent funny characters on Home Page
- Remove the height limit on wordpress 3.4.2
- What is zinging my HTML commands? I don’t think I can blame TinyMCE this time…
- Post removes any text from post that’s following special characters
- Category that can hold only specific number of post
- wp trim function not working
- How to make sure the letters ‘pez’ do not convert to a fish symbol? [closed]
- Limit taxonomy terms added to a custom post type
- Limit total tags in the_content