2016-10-09 7 views
3

Wordpress에서 RecentPost Carousel을 PHP 및 BxSlider와 함께 만들 필요가 있지만 미리보기 이미지를 표시 할 수 없습니다. Wordpress에서 최신 포스트 회전식을 만드는 방법

나는 다음 코드를 사용하여 최근의 게시물이 있습니다

<?php 
    $recent_posts = wp_get_recent_posts(); 
    foreach($recent_posts as $recent){ 
     echo '<li><a href="' . get_permalink($recent["ID"]) . '">' . $recent["post_title"].'</a> </li> '; 
    } 
    wp_reset_query(); 
    ?> 

이 코드는 마지막 게시물을 표시하고 완벽하게 작동하고 있지만, 어떻게 미디어 라이브러리의 기능을 갖춘 이미지 또는 썸네일 이미지를 얻을 수 있습니까?

답변

0

이 시도 - 도움을

<?php 
$args = array(
    'numberposts' => 10, //number of post. 
    'post_type' => 'post', 
    'post_status' => 'publish' 
); 
$recent_posts = wp_get_recent_posts(); 
foreach($recent_posts as $recent){ 
    echo '<li><a href="' . get_permalink($recent["ID"]) . '">' .get_the_post_thumbnail($recent["ID"], 'thumbnail'). $recent["post_title"].'</a> </li> '; 
} 
wp_reset_query(); 
?> 
+0

감사합니다! 지금 일하고있다. – cfranco

0

시도해 보셨습니까?

get_the_post_thumbnail($post_id, 'thumbnail');  // Thumbnail (Note: different to Post Thumbnail) 
get_the_post_thumbnail($post_id, 'medium');   // Medium resolution 
get_the_post_thumbnail($post_id, 'large');   // Large resolution 
get_the_post_thumbnail($post_id, 'full');   // Original resolution 

https://developer.wordpress.org/reference/functions/get_the_post_thumbnail/

또는이?

//Default WordPress 
the_post_thumbnail('thumbnail');  // Thumbnail (150 x 150 hard cropped) 
the_post_thumbnail('medium');  // Medium resolution (300 x 300 max height 300px) 
the_post_thumbnail('medium_large'); // Medium Large (added in WP 4.4) resolution (768 x 0 infinite height) 
the_post_thumbnail('large');   // Large resolution (1024 x 1024 max height 1024px) 
the_post_thumbnail('full');   // Full resolution (original size uploaded) 

https://developer.wordpress.org/reference/functions/the_post_thumbnail/