Skip to content

Instantly share code, notes, and snippets.

@imarkdesigns
Created September 25, 2019 01:19
Show Gist options
  • Save imarkdesigns/884fca79db8ec87a214a536eabff4d19 to your computer and use it in GitHub Desktop.
Save imarkdesigns/884fca79db8ec87a214a536eabff4d19 to your computer and use it in GitHub Desktop.
Paginate Custom Post Types from CSS-Tricks #wp #php
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('showposts=6&post_type=news'.'&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
<!-- LOOP: Usual Post Template Stuff Here-->
<?php endwhile; ?>
<nav>
<?php previous_posts_link('&laquo; Newer') ?>
<?php next_posts_link('Older &raquo;') ?>
</nav>
<?php
$wp_query = null;
$wp_query = $temp; // Reset
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment