我正在尝试使用此代码在我的Wordpress页面上仅提取“静止图像”类别。我尝试了一些不同的东西,但它只是拉出了所有类别的缩略图。
<?php
$args = array( 'numberposts' => '12' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
if ( has_post_thumbnail($recent["ID"])) {
echo '<li>' . get_the_post_thumbnail($recent["ID"], 'thumbnail') . '</li>';
}
}?>
答案 0 :(得分:0)
您可以尝试:
<?php
$args = array( 'numberposts' => '12' );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
if ( has_post_thumbnail() ) {
if (is_category('stills')){
the_post_thumbnail( 'thumbnail' );
}
}
}?>