시작.
// Get all our posts, and start the counter
$postNumber = 0;
$args = array(
'posts_per_page' => 8
);
$posts = get_posts($args);
// Loop through each of our posts
foreach ($posts as $post) {
// If we're at the first post, or just before a post number that is divisible by three then we start a new row
if (($postNumber == 0) || (($postNumber+1) % 3 == 0)) {
echo '<div class="row">';
}
// Choose the post class based on what number post we are
$postClass = '';
if ($postNumber == 0) {
$postClass .= "col-md-8";
} else {
$postClass .= "col-md-4";
}
echo '<div class="'.$postClass.'">';
// Print the post data...
echo $postNumber. " " . $postClass;
echo "</div>";
// If we are at the second post, or we're just after a post number divisible by three we are at the end of the row
if (($postNumber == 1) || (($postNumber-1) % 3 == 0)) {
echo '</div>'; // close row tag
}
$postNumber++; // Increment counter
}
이이 같은 몇 가지 출력을 제공합니다 :
당신은 분명히 당신의 템플릿을 기반으로이를 수정해야하지만 나는 그렇게 같은 게시물을 통해 다음 루프를 거라고 당신에게 좋은 출발점을 주어야합니다.
시도해보고 코드를 게시하십시오! –