Skip to content

Instantly share code, notes, and snippets.

@wbcomdev
Last active June 7, 2021 12:26
Show Gist options
  • Select an option

  • Save wbcomdev/a057d6481bb46ff71bfa95d6bae3aeb3 to your computer and use it in GitHub Desktop.

Select an option

Save wbcomdev/a057d6481bb46ff71bfa95d6bae3aeb3 to your computer and use it in GitHub Desktop.
<?php
/**
* Set Limit of content length.
*
* @param mixed $content
* @return void
*/
function wbcom_limit_content_length( $content ) {
if ( 'post' === get_post_type() ) {
return mb_strimwidth( strip_tags( $content ), 0, 100, '...' );
} else {
return $content;
}
}
add_filter( 'the_content', 'wbcom_limit_content_length' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment