Ver Mensaje Individual
  #4 (permalink)  
Antiguo 06/10/2010, 14:32
Avatar de Nekko
Nekko
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Buenos Aires
Mensajes: 3.141
Antigüedad: 16 años, 1 mes
Puntos: 656
Respuesta: imagen previa en el index

En el functions.php podés poner una función para que encuentre automáticamente la imagen

Código PHP:
/* Catch that image II */
// Obtener la URL de la primer imagen en el post
function catch_that_image() {
global 
$post$posts;
$first_img '';
ob_start();
ob_end_clean();
$output preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i'$post->post_content$matches);
$first_img $matches [1] [0];

// si no encuentra una imagen, que busque en el custom field 'thumbs'
if(empty($first_img)){
$first_img get_post_meta($post->ID'thumbs'$single true);
}
return 
$first_img;

Y en tu home, dentro del loop, llamás a la imagen asi (usando timthumb):

Código PHP:
<img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo catch_that_image(); ?>&h=40&w=80&zc=1" alt="<?php the_title(); ?>" />
En summarg tengo posteadas algunas cositas sobre como usar timthumb (es la costumbre, pero Metacortex tiene un plugin desarrollado también)
__________________
Taller para crear themes wordpress desde cero | Presupuestos para trabajos particulares vía MP