Ver Mensaje Individual
  #3 (permalink)  
Antiguo 31/07/2012, 07:40
Avatar de Nekko
Nekko
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Buenos Aires
Mensajes: 3.141
Antigüedad: 16 años
Puntos: 656
Respuesta: Duda con Excerpt

Te dejo un compilado de snippets que sirven para tal fin
http://www.summarg.com/2012/limitar-...-en-wordpress/

Yo todavía uso el de "La Bitácora"

Código PHP:
Ver original
  1. /*
  2. Original Plugin URI: http://labitacora.net/comunBlog/limit-post.phps
  3. Usage: the_content_limit($max_charaters, $more_link)
  4. */
  5.  
  6. function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
  7.     $content = get_the_content($more_link_text, $stripteaser, $more_file);
  8.     $content = apply_filters('the_content', $content);
  9.     $content = str_replace(']]>', ']]>', $content);
  10.     $content = strip_tags($content);
  11.  
  12.    if (strlen($_GET['p']) > 0) {
  13.         echo "<p>";
  14.         echo $content;
  15.         echo "...";
  16.         echo "&nbsp;<a href='";
  17.         the_permalink();
  18.         echo "'>".$more_link_text."</a>";
  19.         echo "</p>";
  20.    }
  21.    else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {
  22.         $content = substr($content, 0, $espacio);
  23.         $content = $content;
  24.         echo "<p>";
  25.         echo $content;
  26.         echo "...";
  27.         echo "&nbsp;<a href='";
  28.         the_permalink();
  29.         echo "'>Leer nota</a>";
  30.         echo "</p>";
  31.    }
  32.    else {
  33.         echo "<p>";
  34.         echo $content;
  35.         echo "...";
  36.         echo "&nbsp;<a href='";
  37.         the_permalink();
  38.         echo "'>Leer nota</a>";
  39.         echo "</p>";
  40.    }
  41. }

y su uso:

Código PHP:
Ver original
  1. <?php*the_content_limit('150'); ?>

Saludos!
__________________
Taller para crear themes wordpress desde cero | Presupuestos para trabajos particulares vía MP