Ver Mensaje Individual
  #2 (permalink)  
Antiguo 10/01/2010, 08:44
toniveas
 
Fecha de Ingreso: diciembre-2001
Mensajes: 118
Antigüedad: 22 años, 3 meses
Puntos: 0
Respuesta: Como recoger la url de las imagenes de un post

Encontré la solución "tuneando" otro codigo que utilizaba:

En functions.php copio lo siguiente:
Código PHP:
<?php 
// Función para extraer imagen de artículo.

function imatge($tamany '') {
  if ( 
$images get_children( array (
    
'post_parent'    => get_the_ID(),
    
'post_type'      => 'attachment',
    
'numberposts'    => 1,
    
'post_mime_type' => 'image'
   
)));
  {
    if(!empty(
$images)) { //Solo añadí esta línea
        
foreach( $images as $image ) {
          if(
$tamany == 'llistat_url') {
          
$imagen wp_get_attachment_image_src$image->ID'thumbnail' );
          echo 
$imagen[0];
          } if(
$tamany == 'destacat_url') {
          
$imagen wp_get_attachment_image_src$image->ID'medium' );
          echo 
$imagen[0];
          } if(
$tamany == 'portada_url') {
          
$imagen wp_get_attachment_image_src$image->ID'full' );
          echo 
$imagen[0];
          }
          if(
$tamany == 'llistat') {
          
$imagen wp_get_attachment_image$image->ID'thumbnail' );
          echo 
$imagen;
          } if(
$tamany == 'destacat') {
          
$imagen wp_get_attachment_image$image->ID'medium' );
          echo 
$imagen;
          } if(
$tamany == 'portada') {
          
$imagen wp_get_attachment_image$image->ID'full' );
          echo 
$imagen;
          }
        }
    } 
// y su respectivo cierre    
  
}
}
?>
Y basta con pegar el siguiente codigo dentro del loop:
Código PHP:
<?php imatge($tamany 'portada_url'); ?>
Basta con substituir el valor de "tamany" por llistat, destacat o portada para obtener la imagen y llistat_url, destacat_url o portada_url para obtener la url de la imagen.

Seguro que habrán opciones mejores, y por ése motivo os dejo éste aporte.