<div>
<div>
<div>1</div>
<div>2</div>
<div>3</div>
</div>
<div>
<div>4</div>
<div>5</div>
<div>6</div>
</div>
<div>
<div>7</div>
<div>8</div>
<div>9</div>
</div>
<div>
<div>10</div>
<div>11</div>
<div>12</div>
</div>
</div>
<?php
$args = array(
'post_type' => 'projects',
'posts_per_page' => 9,
);
$projects_posts = array_chunk(get_posts( $args ), 3);
?>
<?php
foreach($projects_posts as $projectKey => $post) :
echo '<div class="portfolio_cards">';
foreach($post as $postValue) :
?>
<div class="portfolio_card">
<img src="<?php echo the_post_thumbnail_url( 'full', $postValue ); ?>" alt="photo">
<div class="internal_slider">
<div class="internal_slide_text">
<div class="icons">
<?php echo carbon_get_post_meta( get_the_ID(), 'projects-item-slider-icons' ); ?>
</div>
<span class="card_header">
<?php echo carbon_get_post_meta( get_the_ID(), 'projects-item-slider-name' ); ?>
</span>
<p class="p">
<?php echo carbon_get_post_meta( get_the_ID(), 'projects-item-slider-desc' ); ?>
</p>
</div>
<a href="portfolio-card.html" class="about_internal_slider_pagination internal_pagination"></a>
<div class="swiper about_internal_slider_name">
<div class="swiper-wrapper">
<?php
$projectsInternalData = carbon_get_post_meta( get_the_ID(), 'projects-item-slider' );
if (!empty($projectsInternalData)) :
foreach($projectsInternalData as $projectsInternal => $projectsInternalItem) :
?>
<div class="swiper-slide">
<img src="<?php echo esc_html( $projectsInternalItem['projects-item-slider-image'] ) ?>" alt="image">
<div class="overlay"></div>
</div>
<?php
endforeach;
endif;
?>
</div>
</div>
</div>
</div>
<?php
endforeach;
echo '</div>';
endforeach;
?>
<div>
// Задаем нужные нам критерии выборки данных из БД.
$args = array(
'post_type' => 'projects',
'posts_per_page' => 9,
);
$query = new WP_Query( $args );
$counter = 1;
// Цикл.
if ( $query->have_posts() ) {
echo '<div>';
while ( $query->have_posts() ) {
$query->the_post();
echo '<div>' . get_the_title() . '</div>';
if ( is_int( $counter / 3 ) ) {
echo '</div>';
echo '<div>';
}
$counter++;
}
echo '</div>';
}
else {
// Постов не найдено.
}
// Возвращаем оригинальные данные поста. Сбрасываем $post.
wp_reset_postdata();