Foros del Web » Creando para Internet » Sistemas de gestión de contenidos » WordPress »

Extractos en entradas (avanzado)

Estas en el tema de Extractos en entradas (avanzado) en el foro de WordPress en Foros del Web. Hola compañeros, estoy trasteando con un theme (estilo magazine) para www.hiphopyaik.com , como veis arriba hay cuatro columnas para cada categoría con miniatura, título y ...
  #1 (permalink)  
Antiguo 22/03/2010, 13:01
Avatar de ManuelAlejandro  
Fecha de Ingreso: noviembre-2009
Ubicación: Alicante
Mensajes: 87
Antigüedad: 14 años, 5 meses
Puntos: 6
Extractos en entradas (avanzado)

Hola compañeros, estoy trasteando con un theme (estilo magazine) para www.hiphopyaik.com, como veis arriba hay cuatro columnas para cada categoría con miniatura, título y extracto, pero abajo en la columna Lo último aparecen sólo los títulos y las miniaturas, me gustaría saber cómo puedo añadir a esa columna también los extractos.

No sé si debo añadir alguna variable... no tengo ni idea, el código de dicha columna es:

<?php _e('Lo &uacute;ltimo', 'kubrick'); ?> (no sé si enlaza con functions.php o con qué).

A ver si podéis darme alguna orientación, si necesitáis algún código más sólo decidme.

Muchísimas gracias ^^
  #2 (permalink)  
Antiguo 23/03/2010, 04:07
 
Fecha de Ingreso: septiembre-2008
Ubicación: Lanzarote, Canarias
Mensajes: 486
Antigüedad: 15 años, 7 meses
Puntos: 41
Respuesta: Extractos en entradas (avanzado)

Hombre... si no pones nada más que eso no se puede decir donde añadirlo... eso es simplemente un texto.

Solo tienes que poner:

Código:
 <?php the_excerpt(); ?>
Donde quieras que salga y listo...
  #3 (permalink)  
Antiguo 23/03/2010, 09:04
Avatar de ManuelAlejandro  
Fecha de Ingreso: noviembre-2009
Ubicación: Alicante
Mensajes: 87
Antigüedad: 14 años, 5 meses
Puntos: 6
Respuesta: Extractos en entradas (avanzado)

Muchas gracias codig0, yo no sé mucho pero creo que este código:

<?php _e('Lo &uacute;ltimo', 'kubrick'); ?>

enlazará a algún sitio donde estarán las propiedades ¿no? lo que no sé es a donde... ^^
  #4 (permalink)  
Antiguo 23/03/2010, 09:48
 
Fecha de Ingreso: septiembre-2008
Ubicación: Lanzarote, Canarias
Mensajes: 486
Antigüedad: 15 años, 7 meses
Puntos: 41
Respuesta: Extractos en entradas (avanzado)

Nop, eso no enlaza nada... eso es simplemente una función que tiene wordpress para hacer multilenguaje el theme, por eso no sale directamente "Lo último", sino métido dentro de _e();
  #5 (permalink)  
Antiguo 24/03/2010, 06:49
Avatar de ManuelAlejandro  
Fecha de Ingreso: noviembre-2009
Ubicación: Alicante
Mensajes: 87
Antigüedad: 14 años, 5 meses
Puntos: 6
Respuesta: Extractos en entradas (avanzado)

Ahh entiendo, vale pues voy a hacer pruebas con <?php the_excerpt(); ?>
  #6 (permalink)  
Antiguo 24/03/2010, 06:54
Avatar de ManuelAlejandro  
Fecha de Ingreso: noviembre-2009
Ubicación: Alicante
Mensajes: 87
Antigüedad: 14 años, 5 meses
Puntos: 6
Respuesta: Extractos en entradas (avanzado)

¡codig0 eres un ídolo de masas! ya funciona ^^ muchísimas gracias, lo que hice fue entrar a post.php que es lo que regula esa parte y añadir debajo del h2 el código que me diste

Gracias!!
  #7 (permalink)  
Antiguo 24/03/2010, 07:29
 
Fecha de Ingreso: septiembre-2008
Ubicación: Lanzarote, Canarias
Mensajes: 486
Antigüedad: 15 años, 7 meses
Puntos: 41
Respuesta: Extractos en entradas (avanzado)

Lo de el archivo post.php es cosa de el theme, ya que el archivo de los post es single.php, pero deben haber puesto un include en ese theme.

Por cierto, veo que sale demasiado texto ahí, lo que haría yo sería meter esta función en functions.php (si no existe, creálo) de tu theme.

Código:
function 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(']]>', ']]&gt;', $content);
  $content = strip_tags($content);
  return $content;
}
y en ves de poner:

Código:
<?php the_excerpt(); ?>
pon esto otro:

Código:
<?php content('20');?>
20 es el número de carácteres que quieres mostrar.
  #8 (permalink)  
Antiguo 26/03/2010, 21:55
Avatar de ManuelAlejandro  
Fecha de Ingreso: noviembre-2009
Ubicación: Alicante
Mensajes: 87
Antigüedad: 14 años, 5 meses
Puntos: 6
Respuesta: Extractos en entradas (avanzado)

¡Qué bueno! Muchas gracias, voy a quitarle texto sí, si no sale demasiado cargado, muchísimas gracias por tu ayuda
  #9 (permalink)  
Antiguo 30/05/2010, 06:43
Avatar de ManuelAlejandro  
Fecha de Ingreso: noviembre-2009
Ubicación: Alicante
Mensajes: 87
Antigüedad: 14 años, 5 meses
Puntos: 6
Respuesta: Extractos en entradas (avanzado)

Hola de nuevo, reactivo este post porque acabo de probar lo que me aconsejaste codig0 pero al cambiarlo se elimina totalmente el texto, no se limitan los caracteres sino que desaparecen... ¿alguna idea?

Gracias!
  #10 (permalink)  
Antiguo 30/05/2010, 07:00
Avatar de ManuelAlejandro  
Fecha de Ingreso: noviembre-2009
Ubicación: Alicante
Mensajes: 87
Antigüedad: 14 años, 5 meses
Puntos: 6
Respuesta: Extractos en entradas (avanzado)

Y aprovechando el post planteo una nueva duda, arriba hay cuatro categorías, cuatro bloques entre los que está por ejemplo la categoría de Actualidad Reciente, ahí aparece el título y un extracto del texto, me gustaría que sólo apareciera el título pero no logro quitar el texto, estoy en functions.php y el código es este:

Código:
$wps_categories_obj = get_categories('hide_empty=0');
$wps_categories = array();
foreach ($wps_categories_obj as $wps_cat) {
  $wps_categories[$wps_cat->cat_ID] = $wps_cat->cat_name;
}

$categories_tmp = array_unshift($wps_categories, "Select a category:");
$number_entries = array("Select a Number:","1","2","3","4","5","6","7","8","9","10");

  array(	"name" => "Featured Posts Carousel Settings",
    "type" => "heading"),

	array(	"name" => "Number of items",
    "desc" => "Select the number of items to display in Featured Posts Carousel.",
    "id" => "wps_feat_carousel_items",
    "std" => "Select a Number:",
    "type" => "select",
    "options" => $number_entries),

  array(	"name" => "Disable Featured Posts Carousel",
    "desc" => 'Check this box if you would like to DISABLE the Featured Posts Carousel.<br /><br />',
    "id" => "wps_feat_carousel_enable",
    "std" => "false",
    "type" => "checkbox"),

	array(  "name" => "Featured Category Settings",
    "type" => "heading"),

  array( 	"name" => "Featured Category 1",
    "desc" => "Select the category. The Recent posts from this category will be displayed on homepage.",
    "id" => "wps_feat1",
    "std" => "Select a category:",
    "type" => "select",
    "options" => $wps_categories),

  array(	"name" => "Featured Category 1 Title",
    "desc" => 'Please enter your Featured Category 1 Title.<br /><br />',
    "id" => "wps_feat1_title",
    "std" => "Enter Featured Category 1 Title here",
    "type" => "text"),

	array(	"name" => "Number of items in Featured Category 1",
    "desc" => "Select the number of items to display on featured Category 1.",
    "id" => "wps_feat1_items",
    "std" => "Select a Number:",
    "type" => "select",
    "options" => $number_entries),

  array( 	"name" => "Featured Category 2",
    "desc" => "Select the category. The Recent posts from this category will be displayed on homepage.",
    "id" => "wps_feat2",
    "std" => "Select a category:",
    "type" => "select",
    "options" => $wps_categories),

  array(	"name" => "Featured Category 2 Title",
    "desc" => 'Please enter your Featured Category 2 Title.<br /><br />',
    "id" => "wps_feat2_title",
    "std" => "Enter Featured Category 2 Title here",
    "type" => "text"),

  array(	"name" => "Number of items in Featured Category 2",
    "desc" => "Select the number of items to display on featured Category 2.",
    "id" => "wps_feat2_items",
    "std" => "Select a Number:",
    "type" => "select",
    "options" => $number_entries),

  array( 	"name" => "Featured Category 3",
    "desc" => "Select the category. The Recent posts from this category will be displayed on homepage.",
    "id" => "wps_feat3",
    "std" => "Select a category:",
    "type" => "select",
    "options" => $wps_categories),

  array(	"name" => "Featured Category 3 Title",
    "desc" => 'Please enter your Featured Category 3 Title.<br /><br />',
    "id" => "wps_feat3_title",
    "std" => "Enter Featured Category 3 Title here",
    "type" => "text"),

  array(	"name" => "Number of items in Featured Category 3",
    "desc" => "Select the number of items to display on featured Category 3.",
    "id" => "wps_feat3_items",
    "std" => "Select a Number:",
    "type" => "select",
    "options" => $number_entries),

  array( 	"name" => "Featured Category 4",
    "desc" => "Select the category. The Recent posts from this category will be displayed on homepage.",
    "id" => "wps_feat4",
    "std" => "Select a category:",
    "type" => "select",
    "options" => $wps_categories),

  array(	"name" => "Featured Category 4 Title",
    "desc" => 'Please enter your Featured Category 4 Title.<br /><br />',
    "id" => "wps_feat4_title",
    "std" => "Enter Featured Category 4 Title here",
    "type" => "text"),

  array(	"name" => "Number of items in Featured Category 4",
    "desc" => "Select the number of items to display on featured Category 4.",
    "id" => "wps_feat4_items",
    "std" => "Select a Number:",
    "type" => "select",
    "options" => $number_entries),

  array(	"name" => "Disable Featured Category Block",
    "desc" => 'Check this box if you would like to DISABLE the featured Category Block.<br /><br />',
    "id" => "wps_feat_enable",
    "std" => "true",
    "type" => "checkbox"),

	array(	"name" => "Featured Video Settings",
    "type" => "heading",
    "desc" => "<small>Please enter the Video code here. Modify the width to 315 and height to 236.</small>"),

  array(	"name" => "Featured Video Code",
    "desc" => 'Please enter your the featured video code.<br /><br />',
    "id" => "wps_vid",
    "std" => "Enter featured video code here.",
    "type" => "textarea"),

  array(	"name" => "Disable Featured Video Widget",
    "desc" => 'Check this box if you would like to DISABLE the featured video widget.<br /><br />',
    "id" => "wps_vid_enable",
    "std" => "true",
    "type" => "checkbox"),

	array(	"name" => "468x60 Homepage Banner Ad 1 Settings",
    "type" => "heading",
    "desc" => "<small>You can specify ads (google ad/affiliate ad/banner) on this section. The ad will be displayed on 468x60 Homepage Header Banner.</small>"),

  array(	"name" => "468x60 Banner Ad",
    "id" => "wps_home_ad_468",
    "std" => "Enter 468x60 Ad Code Here",
    "type" => "textarea"),

  array(	"name" => "Disable 468x60 header Banner Ad",
    "desc" => 'Check this box if you would like to DISABLE the 468x60 header Banner Ad.<br /><br />',
    "id" => "wps_home_ad_468_enable",
    "std" => "false",
    "type" => "checkbox"),

  array(	"name" => "468x60 Homepage Banner Ad 2 Settings (under featured posts)",
    "type" => "heading",
    "desc" => "<small>You can specify ads (google ad/affiliate ad/banner) on this section. The ad will be displayed under featured posts (only on home page).</small>"),

  array(	"name" => "468x60 Banner Ad",
    "id" => "wps_home_ad_468_2",
    "std" => "Enter 468x60 Ad Code Here",
    "type" => "textarea"),

  array(	"name" => "Disable 468x60 home page Ad",
    "desc" => 'Check this box if you would like to DISABLE the 468x60 home page Ad (under featured posts).<br /><br />',
    "id" => "wps_home_ad_468_2_enable",
    "std" => "false",
    "type" => "checkbox"),

  array(	"name" => "468x60 innerpage Banner Ad Settings",
    "type" => "heading",
    "desc" => "<small>You can specify ads (google ad/affiliate ad/banner) on this section. The ad will be displayed on 468x60 innerpages below Title of the post.</small>"),

  array(	"name" => "468x60 innerpage Banner Ad",
    "id" => "wps_inner_ad_468",
    "std" => "Enter 468x60 Ad Code Here",
    "type" => "textarea"),

  array(	"name" => "Disable 468x60 innerpage Banner Ad",
    "desc" => 'Check this box if you would like to DISABLE the 468x60 innerpage Banner Ad.<br /><br />',
    "id" => "wps_inner_ad_468_enable",
    "std" => "false",
    "type" => "checkbox"),

  array(	"name" => "300x250 Sidebar Banner Ad Settings",
    "type" => "heading",
    "desc" => "<small>You can specify ads (google ad/affiliate ad/banner) on this section. The ad will be displayed on 300x250 Right Sidebar.</small>"),

  array(	"name" => "300x250 Sidebar Banner Ad",
    "id" => "wps_ad_300x250",
    "std" => "Enter 300x250 Ad Code Here",
    "type" => "textarea"),

  array(	"name" => "Disable 300x250 Sidebar Banner Ad",
    "desc" => 'Check this box if you would like to DISABLE the 300x250 Sidebar Banner Ad.<br /><br />',
    "id" => "wps_ad_300x250_enable",
    "std" => "false",
    "type" => "checkbox"),

  array(	"name" => "Popular Posts Settings",
    "type" => "heading",
    "desc" => "<small>You can customize Popular posts which is shown on Sidebar on this section.</small>"),

  array(	"name" => "Number of items",
    "desc" => "Select the number of items to display on Popular Posts.",
    "id" => "wps_popu_items",
    "std" => "Select a Number:",
    "type" => "select",
    "options" => $number_entries),
Creo que la zona que determina la configuración de estos bloques está por Featured Category Settings, pero aun así no logro quitarle el texto... ¿alguna idea?

¡MUCHÍSIMAS GRACIAS CHICOS!

Pd. He pegado sólo una parte del código, si hace falta toda la página decídmelo y la enlazo desde un .txt
  #11 (permalink)  
Antiguo 30/05/2010, 08:32
 
Fecha de Ingreso: septiembre-2008
Ubicación: Lanzarote, Canarias
Mensajes: 486
Antigüedad: 15 años, 7 meses
Puntos: 41
Respuesta: Extractos en entradas (avanzado)

falta echo...

Código:
<?php echo content('20');?>
  #12 (permalink)  
Antiguo 03/06/2010, 14:35
Avatar de ManuelAlejandro  
Fecha de Ingreso: noviembre-2009
Ubicación: Alicante
Mensajes: 87
Antigüedad: 14 años, 5 meses
Puntos: 6
Respuesta: Extractos en entradas (avanzado)

Genial, ahora sí, muchas gracias!

Etiquetas: entradas
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:33.