Last active
December 16, 2015 19:59
-
-
Save benschaaf/5489057 to your computer and use it in GitHub Desktop.
Custom Post Type - Pagination Issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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('« Newer'); | |
next_posts_link('Older »'); ?> | |
<?php endif; wp_reset_query(); ?> | |
</section> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment