Olá pessoal,
A minha dúvida é a seguinte, fiz o código abaixo para chamar os últimos 6 artigos mostrando uma imagem (no lugar o texto) formando link. A imagem é chamada via Custom Fields e possui o script timthumb para redimensionar a figura.
Quero colocar a chamada da função num widget (usando exec-PHP), porém, ele pula a condição do if para verificar o Custom, vai direto para else.
Porém, usando o código (com as devidas adaptações, mas sem mexer na essência dele) diretamente no sidebar, ele funciona perfeitamente.
Alguém teria uma luz?
function recente( $iQnt = 6 )
{
$ultimos = new WP_Query( "showposts=" . $iQnt);
while($ultimos->have_posts()) : $ultimos->the_post();
if ( get_post_meta($post->ID,'recente',true) ) {
$recent .= '<a href="' . get_permalink() . '" title= " '. get_the_title(). '">
<img src=" '. get_bloginfo('wpurl').' /wp-content/scripts/timthumb.php?src='.get_post_meta($post->ID, 'recente',true).'&w=75&h=75&zc=1" width="75" height="75" alt=" '. get_the_title(). '" /></a>';
}
else {
$recent .= '<a href="' . get_permalink() . '" title= " '. get_the_title(). '">
<img src=" '.get_bloginfo('template_directory').'/images/semfoto.jpg" width="75" height="75" alt=" '. get_the_title(). '" /></a>';
}
endwhile;
echo $recent;
}