+ Babaman Publicado 29 de Noviembre del 2019 Reportar Compartir Publicado 29 de Noviembre del 2019 (editado) You use the_content function in almost every page of your dooplay theme. For instance you use in peliculas.php, series.php file and it will echo all the content for one post or page. But you don’t want to show all content. Maybe only 80 words. Here how you can limit the_content Using Custom Function This method is going to be the best and most flexible way to limit the_content words length. Write the following custom function in your functions.php file. function dooplay_content($limit){ $content = explode(' ', get_the_content(), $limit); if (count($content)>=$limit){ array_pop($content); $content = implode(" ",$content).'...'; } else { $content = implode(" ",$content); } $content = preg_replace('/\[.+\]/','', $content); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); return $content; } Use the custom function instead of the_content. For example: <?php echo dooplay_content(80); ?> Editado 29 de Noviembre del 2019 por Babaman Enlace al comentario Compartir en otros sitios web More sharing options...
Publicaciones recomendadas