Answer the question
In order to leave comments, you need to log in
How to implement the output of 6 articles in 1 slide (on the slider)?
Good afternoon!
Tell me what the problem is, I can not figure it out! I hope for you)
The essence of the question is as follows, it is necessary to display 6 articles in 1 slide. I seem to write correctly, but the layout gets lost.
<div id="all" class="tabs__content-item owl-carousel owl-theme active">
<div class="slide">
<div class="invest-project-list">
<?php
$posts = get_posts( array(
'numberposts' => 8,
'category' => 0,
'orderby' => 'date',
'order' => 'DESC',
'include' => array(),
'exclude' => array(),
'meta_key' => '',
'meta_value' =>'',
'post_type' => 'post',
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
) ); ?>
<?php foreach( $posts as $k => $post ){ setup_postdata($post); ?>
<div class="invest-project-item">
<div class="item-img-wrapper">
<img class="item-img" src="<?php echo get_the_post_thumbnail_url(); ?>" alt="Недвижимость">
<div class="item-type-block"><p class="item-type">
Недвижимость
</p>
</div>
</div>
<h3 class="item-title">Лидеры инноваций</h3>
<p class="item-subtitle">Акции инновационных компаний</p>
<span class="item-breakline"></span>
<div class="item-property">
<p>Доход:</p>
<p><?php echo get_post_meta(get_the_ID(), 'profitability_text', true ); ?></p>
</div>
<div class="item-property">
<p>Сумма от:</p>
<p><?php echo get_post_meta(get_the_ID(), 'invest_cash', true ); ?></p>
</div>
<div class="item-property">
<p>Срок инвестирования:</p>
<p><?php echo get_post_meta(get_the_ID(), 'invest_date', true ); ?></p>
</div>
<div class="item-property">
<p>Формат выплат:</p>
<p><?php echo get_post_meta(get_the_ID(), 'invest_format_mini', true ); ?></p>
</div>
<div class="item-property">
<p>Гарантии:</p>
<p><?php echo get_post_meta(get_the_ID(), 'invest_guaranties_mini', true ); ?></p>
</div>
<a class="btn detailed-button" href="<?php the_permalink(); ?>">Подробнее</a>
</div>
<?php if ($k % 6 !== 0) { ?> </div><div class="invest-project-list"> <?php } ?>
<?php
}
wp_reset_postdata(); // сброс
?>
</div>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
Solved the problem. I'll leave the code, maybe it will be useful to someone)
<div class="tabs__content">
<div id="all" class="tabs__content-item owl-carousel owl-theme active">
<div class="slide">
<div class="invest-project-list">
<?php
$query = new WP_Query(array(
'post_type' => 'investproj',
'posts_per_page' => -1,
)
);
$i = 1;
while ($query->have_posts()) {
$query->the_post();
?>
<div class="invest-project-item">
<div class="item-img-wrapper">
<img class="item-img" src="<?php echo get_the_post_thumbnail_url(); ?>" alt="Недвижимость">
<div class="item-type-block"><p class="item-type">
<?php single_cat_title(''); ?>
</p>
</div>
</div>
<h3 class="item-title">Лидеры инноваций</h3>
<p class="item-subtitle">Акции инновационных компаний</p>
<span class="item-breakline"></span>
<div class="item-property">
<p>Доходность:</p>
<p><?php echo get_post_meta(get_the_ID(), 'profitability_text', true ); ?></p>
</div>
<div class="item-property">
<p>Сумма инвестиций от:</p>
<p><?php echo get_post_meta(get_the_ID(), 'invest_cash', true ); ?></p>
</div>
<div class="item-property">
<p>Срок инвестирования:</p>
<p><?php echo get_post_meta(get_the_ID(), 'invest_date', true ); ?></p>
</div>
<div class="item-property">
<p>Формат выплат:</p>
<p><?php echo get_post_meta(get_the_ID(), 'invest_format_mini', true ); ?></p>
</div>
<div class="item-property">
<p>Гарантии:</p>
<p><?php echo get_post_meta(get_the_ID(), 'invest_guaranties_mini', true ); ?></p>
</div>
<a class="btn detailed-button" href="<?php the_permalink(); ?>">Подробнее</a>
</div>
<?php
// это 6 блок
if( ! ($i++ % 6) ){
?>
</div>
</div><div class="invest-project-list">
<?php
}}
wp_reset_postdata(); // сброс
?>
</div>
</div>
</div>
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question