Wordpress에서는 첫 번째 게시물의 게시물 축소판과 함께 2 개의 최신 게시물을 표시하려고합니다.Wordpress에서 최신 게시물의 이미지를 표시하는 방법
나는 아래 코드를 가지고 놀았지만 이미지는 첫 번째 이미지뿐만 아니라 두 번째 이미지에도 항상 표시됩니다.
<?php
$cat_args = array(
'orderby' => 'name',
'order' => 'ASC',
'child_of' => 0
);
$post_args = array(
'numberposts' => 2,
'category' => $category->term_id
);
$posts = get_posts($post_args);
foreach($posts as $post) {
?>
<?php the_title(); ?>
<?php the_post_thumbnail('blog_post_image'); ?>
<?php
}
}
?>
을 인쇄하기 전에뿐만 아니라
if
등의foreach
에$key
의 추가를 주목하라? –@AdamScott 기존 'foreach' 루프 바꾸기 –