I would like to set up an archive page for tags where posts are displayed separated depending on post format, first post-format-aside then an archive with all posts except the posts already displayed, from-post format-aside.
So first I want 4 posts with the post-format-aside format and then I want an archive but without posts from post-format-aside. As I have tried to do it is with WP-queries but it doesn't feel like a good structure.... This is the code I have set up so far:
<div class="row">
<?php $posts = new WP_Query( array(
'posts_per_page' => 4,
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array(
'post-format-aside'
),
)
)
) );
if ( $posts->have_posts() ) : while ( $posts->have_posts() ) : $posts->the_post(); ?>
<div class="col-sm-3 col-xs-6">
<?php get_template_part( 'content', get_post_format() ); ?>
</div>
<?php endwhile; ?>
<?php endif; wp_reset_query(); ?>
</div>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$posts = ( array(
'post_type' => 'post',
'posts_per_page' => -1,
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array(
'post-format-link'
),
)
)
) );
$query = new WP_query($posts);
if ( $query->have_posts() ) : ?>
<?php rewind_posts(); ?>
<?php while ( $query->have_posts() ) : $query->the_post();
if($i%4==0) {
<div class="row">
<?php } ?>
<div class="col-sm-3 col-xs-6">
<?php get_template_part( 'content', get_post_format() ); ?>
</div>
<?php $i++;
if($i%4==0) { // if counter is multiple of 3, put an closing div ?>
</div>
<?php } ?>
<?php endwhile; wp_reset_query(); ?>
<?php
if($i%4!=0) { // put closing div here if loop is not exactly a multiple of 3 ?>
</div>
<?php } ?>
<div class="blog">
<div class="row">
<div class="col-md-12">
<?php posts_nav_link(); ?>
</div>
</div>
</div>