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?
- Repository size limits for GitHub.com
- 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
- Can I hook into user registration *before* a user is created?
- Decrease file size upload in Media
- Wordspress add into my javascripts
- Problem with Hebrew characters in username
- Customizing get_the_excerpt() to specific length and “Read More” output.
- Different number of posts in each category
- excerpt in characters
- How to Add Customizer Setting in Child Theme
- 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]
- Limiting the number of users
- How can I stop TinyMCE from converting my HTML entities to characters?
- Set a maximum upload count for users on a specific user role
- limit the words in the post content and add read more link
- How to limit user to publish post per day and per role?
- Stop users from logging in from multiple locations
- Is there a limit on the size of a WP page?
- strange characters in wordpress website displayed for visitors [closed]
- Restrict users from editing post based on the age of the post
- Limit number of pages that use a specific template?
- Limit the_excerpt in the first point (.) of the sentence
- Restrict access to post if it is currently being edited
- How can I stop wp_update_post messing up HTML example code?
- Images Missing from built in WP Gallery
- How to increase media image scale limit?
- Divide Post content into separate divs for every 500 characters (or any other character counts)
- Limit the Excerpt field in WP-Admin in words
- Arabic Characters in URL returns 404 Error
- Limit the_excerpt with max of x characters
- Set minimum number of characters in the search
- How to get max upload size and accepted file types on multisite?
- Allowed memory size exhausted. WordPress side solution
- is there any limit of length on creating custom taxonomies?
- Remove empty lines ( ) when author updates their post
- How to limit get_posts()?
- How to stop WordPress from changing ellipsis into a pre-composed triple-dot glyph?
- Limit the number of pages created by the paging
- Comments view limited to 20 results – any way to increase to 50 or 100?
- Adding “ ” before the last word in multiple defined areas with a plugin
- dynamically limit depth of wp_list_pages
- Is there a limit on the number of attachments?
- WordPress turns HTML code to HTML entities
- Character Encoding for wp_options
- WP_Query posts_per_page ignored
- How to limit WP_Query to one result on the loop?
- Get total posts found, but while using limit for pagination? get_posts
- Search and replace special characters (å,ä,ö) for image attachments only in database
- CPT Post Title Permalink: Replace “@” (or all special characters) with dash “-” instead of just removing
- Limit the content entered by editor or admin in the WP admin editor window
- WordPress Defined Memory Limit
- Limited number of paging to 10 “pages: 1 … 10”
- Limiting the number of posts in WP_Query leads to unexpected result
- How do I remove weird characters in text?
- Character Limit w/ Excerpt removes Images Why?
- 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
- RewriteRule accepts numbers but not letters in tag
- Limit posts per author role (excluding admin) in home page
- How to limit comment author to one comment per post
- Restrict users post for himself
- Problem loading custom post type admin page
- Adding special characters to slug?
- why some permalinks adding characters/ruining links
- Get latest 3 posts from multiple CPT in one query
- Limit the menu child levels under “admin > appearance > menus”
- Truncating varying lengths of information
- 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 tag selection to predefined list
- Change/Replace keyboard character on keypress while writing new post
- Limit 1 global comment per minute