Paginate custom post foreach loop by taxonomy
-
I am trying to create an archive list showing a single post from a custom post type sorted by the taxonomy slug and then paginate the list after 5 results. I have successfully produced the list but have no idea how to implement pagination. I would be grateful for any help.
<?php $custom_terms = get_terms('issues'); foreach($custom_terms as $custom_term) { wp_reset_query(); $args = array( 'post_type' => 'news', 'posts_per_page' => '1', 'tax_query' => array( array( 'taxonomy' => 'issues', 'field' => 'slug', 'terms' => $custom_term->slug, ), ), ); $loop = new WP_Query($args); if($loop->have_posts()) { echo '<h2>Edition '.$custom_term->name.'</h2>';?> <h4 class="h6"><?php echo date('l jS F Y'); ?></h4> <?php while($loop->have_posts()) : $loop->the_post(); ?> <div class="newsitem mb20"> <a>"><?php the_title(); ?></a> <?php if (has_post_thumbnail()) :?> <div class="post-imagesmall"><a>"><?php the_post_thumbnail(otherstory); ?></a></div> <?php else : ?> <div class="post-imagesmall"><a>"><img src="/wp-content/upload/thepress-defaultsmall.jpg" /></a></div> <?php endif ?> <?php $myExcerptLength=60; the_excerpt(); ?> <a>">Read More ?</a> <?php echo '<a>slug, 'issues').'">More Articles from this edition</a>'; ?> </div> <?php endwhile; } } ?>
[moderated: please ensure that your code is enclosed in backticks (`) or use the code button. Your code might be broken by the forum’s software]
Viewing 12 replies - 1 through 12 (of 12 total)
Viewing 12 replies - 1 through 12 (of 12 total)
- The topic ‘Paginate custom post foreach loop by taxonomy’ is closed to new replies.