我很难用循环只显示具有特色图片的帖子。我的PHP水平是基本的,任何帮助都会非常有用。
基本上这是我的原始代码:
if( have_posts() ) {
while( have_posts() ) {
the_post();
get_template_part( \'inc/template-parts/content\', $post_layout );
// and some other stuff
}
}
我试过这个帖子的建议-How do I check if a post has a post thumbnail in WP_Query
?但没有任何成功。当我实现代码时,所有帖子都会从头版消失。这是我尝试的代码:
$query = new WP_Query( $thumbs );
$thumbs = array(
\'meta_query\' => array( \'key\' => \'_thumbnail_id\' )
);
if( $query->have_posts() ) {
while( $query->have_posts() ) {
$query->the_post();
get_template_part( \'inc/template-parts/content\', $post_layout );
}
}
如有任何建议,将不胜感激!当做