Answer the question
In order to leave comments, you need to log in
How to list posts with different wp templates?
Hello! I bring out the announcements of all records in a row. The first two posts have their own markup with the news-top wrapper, the rest have their own with the news-bottom wrapper, and this is the question of how to include different templates inside the $posts_news loop? At the moment, this is how I display the records
<?php
$posts_news = get_posts( array(
'numberposts' => -1,
'order' => 'ASC',
'post_type' => 'post_news',
'suppress_filters' => true,
) );
?>
<ul class="news-top">
<?php
foreach( $posts_news as $post ) {
setup_postdata($post);
get_template_part('template-parts/news-block');
}
wp_reset_postdata();
?>
</ul>
<!-- С такой оберткой идет другой шаблон -->
<ul class="news-bottom">
</ul>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question