Created
March 7, 2018 11:55
-
-
Save diegocuruma/eda217ff4356bb02c26e60950b1e2d75 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Limitar número caracteres conteúdo, MAS NÃO CORTA A PALAVRA AO MEIO | |
| **/ | |
| function limitarTexto($content, $limite) | |
| { | |
| $contador = strlen($content); | |
| if ($contador >= $limite) { | |
| $content = substr($content, 0, strrpos(substr($content, 0, $limite), ' ')) . '...'; | |
| return $content; | |
| } else { | |
| return $content; | |
| } | |
| } | |
| <!-- HTML --> | |
| <p> | |
| <?php echo limitarTexto(get_the_content(), 100) ;?> | |
| </p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment