Skip to content

Instantly share code, notes, and snippets.

@benschaaf
Last active December 16, 2015 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benschaaf/5489057 to your computer and use it in GitHub Desktop.
Save benschaaf/5489057 to your computer and use it in GitHub Desktop.
Custom Post Type - Pagination Issue
<?php
// Registering my custom post type
// ...
register_post_type( 'news-event',
array(
'labels' => array(
'name' => __( 'News & Events' ),
'singular_name' => __( 'News & Events' )
),
'public' => true,
'has_archive' => false,
'rewrite' => array('slug' => 'get-involved/news-events', 'with_front' => false),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt' ),
'taxonomies' => array('post_tag', 'category')
)
);
// ...
?>
<?php
// My non-functioning pagination
?>
<section class="news-entries clearfix">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'news-event',
'paged' => $paged
);
$news = new WP_Query( $args );
if ( $news->have_posts() ) :
$count = 1;
while ( $news->have_posts() ) :
$news->the_post();
echo '<div class="news-event-entry entry-">'; ?>
<div class="blog-content">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
</div>
</div>
<?php
endwhile;
previous_posts_link('&laquo; Newer');
next_posts_link('Older &raquo;'); ?>
<?php endif; wp_reset_query(); ?>
</section>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment