作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我需要使用 PHP 和 BxSlider 在 Wordpress 中制作 RecentPost 轮播,但我无法让它显示缩略图。
我有最近的帖子和下一个代码:
<?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();
?>
此代码显示了最后一篇文章并且运行良好,但我如何才能从媒体库中获取特色图像或缩略图或图像?
最佳答案
试试这个 -
<?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();
?>
关于php - 如何在 Wordpress 中制作最近的帖子轮播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39949722/
我是一名优秀的程序员,十分优秀!