I’m trying to get custom archive posts and default posts combined onto one archive page which I have managed… sort of but I can’t get pagination to work either using the pagenavi plugin or the themes default pagination code. I have tried using paged but if anything did show I’m then not sure it would page both categories together or just one.
I need to combine two categories, one a custom taxonomy, the other the default and then have them styled differently and have a set number of the combined posts on the page and to be able have them in pages of 9 posts.
code I’m using:
<?php if (is_category()) { ?>
<h1 class="page-title">
<span><?php _e(); ?></span> <?php single_cat_title(); ?>
</h1>
<?php } ?>
<ul>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part( 'partials/loop', 'archive' ); ?>
<?php endwhile; ?>
</ul>
<?php rewind_posts(); ?>
<?php
$args = array(
'post_type' => 'events',
'posts_per_page' => '6',
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => 'event_cat','events',
'field' => 'slug',
'terms' => 'events','upcoming-events'
)
)
);?>
<?php $the_query = new WP_Query( $args ); ?>
<ul>
<?php if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php get_template_part( 'partials/loop', 'archive-events' ); ?>
<?php endwhile; ?>
</ul>
<?php wp_pagenavi(); ?>
<?php else : ?>
<?php get_template_part( 'partials/content', 'missing' ); ?>
<?php endif; ?>
Changed the above to:
<?php if (is_category()) { ?>
<h1 class="page-title">
<span><?php _e(); ?></span> <?php single_cat_title(); ?>
</h1>
<?php } ?>
<ul class="small-block-grid-1 medium-block-grid-2 large-block-grid-3">
<?php $query = new WP_Query( array( 'cat' => '7' )); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part( 'partials/loop', 'archive' ); ?>
<?php endwhile; ?>
</ul>
<?php else : ?>
<?php get_template_part( 'partials/content', 'missing' ); ?>
<?php endif; ?>
<?php rewind_posts(); ?>
<?php
$args = array(
'post_type' => 'events',
'posts_per_page' => '3',
'paged' => get_query_var( 'paged' ),
'tax_query' => array(
array(
'taxonomy' => 'event_cat',
'field' => 'slug',
'terms' => 'events'
)
)
);?>
<?php $the_query = new WP_Query( $args ); ?>
<ul class="small-block-grid-1 medium-block-grid-2 large-block-grid-3">
<?php if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php get_template_part( 'partials/loop', 'archive-events' ); ?>
<?php endwhile; ?>
</ul>
<?php if (function_exists('joints_page_navi')) { ?>
<?php wp_pagenavi(); ?>
<?php } else { ?>
<nav class="wp-prev-next">
<ul class="clearfix">
<li class="prev-link"><?php next_posts_link(__('« Older Entries', "jointstheme")) ?></li>
<li class="next-link"><?php previous_posts_link(__('Newer Entries »', "jointstheme")) ?></li>
</ul>
</nav>
<?php } ?>
<?php endif; ?>