Is there a way to limit the word count of the post title?
Ive search over the internet but nothing found.
All I know is, only the content of the post can be limit or excerpted.
Is there a way to limit the word count of the post title?
Ive search over the internet but nothing found.
All I know is, only the content of the post can be limit or excerpted.
simply use this where ever you want to display your title with limited words
<?php echo wp_trim_words( get_the_title(), 5 ); ?>
replace number 5 in above code with whatever number of words you need to display.
Regards.
The following will limit the number of characters a user can enter in the admin area, i.e., when writing a post.
add_action( 'admin_head-post.php', 'so_13816272_limit_input_title' );
function so_13816272_limit_input_title( )
{
global $current_screen;
// Not our post type, exit earlier
if( 'post' != $current_screen->post_type )
return;
?>
<script type="text/javascript">
jQuery(document).ready( function($)
{
$('#title').keyup( function()
{
var $this = $(this);
if($this.val().length > 50)
$this.val($this.val().substr(0, 50));
});
});
</script>
<?php
}
If you want to do a word count, refer to this article and adapt the functions into the above code.