Ver Mensaje Individual
  #7 (permalink)  
Antiguo 18/07/2013, 03:57
Avatar de madman_18
madman_18
 
Fecha de Ingreso: agosto-2010
Mensajes: 792
Antigüedad: 13 años, 8 meses
Puntos: 14
Respuesta: Duda: ¿the_excerpt() no respeta los estilos?

Cita:
Iniciado por darchy Ver Mensaje
a mi eso me ha pasado tambien... no recuerdo si es algo que ocurre siempre o no, pero si sé la solución.
en el archivo functions.php de tu theme añade:
Código PHP:
Ver original
  1. /*fix para el excerpt que no hace los saltos de parrafo*/
  2. function improved_trim_excerpt($text) {
  3.         global $post;
  4.         if ( '' == $text ) {
  5.                 $text = get_the_content('');
  6.                 $text = apply_filters('the_content', $text);
  7.                 $text = str_replace('\]\]\>', ']]>', $text);
  8.                 $text = strip_tags($text, '<p>');
  9.                  $excerpt_length = 35; //aqui marca los lo largo que son los excerpts
  10.                
  11.                 $words = explode(' ', $text, $excerpt_length + 1);
  12.                 if (count($words)> $excerpt_length) {
  13.                         array_pop($words);
  14.                         array_push($words, '[...]');
  15.                         $text = implode(' ', $words);
  16.                         $text = force_balance_tags( $text );
  17.                 }
  18.         }
  19.         return $text;
  20. }
He puesto el texto que me comentas, pero me muestra el contenido entero, no lo acorta.

Cuando lo llamo lo hago de la siguiente forma, no sé si es correcto:
Código PHP:
Ver original
  1. improved_trim_excerpt($post->post_content);
__________________
"Si consigues ser algo más que un hombre, si te entregas a un ideal, te convertes en algo muy diferente"