スタート。私はそのようにのような記事をループしたい:
// 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
}
これはあなたにこのようないくつかの出力与える:あなたは明らかにあなたのテンプレートに基づいてこれを変更する必要があります
をこれあなたに素敵な出発点を与えるはずです。
試してコードを投稿してください。 –