WordPress.org

Support

Support » Themes and Templates » Pagination with custom post types

Pagination with custom post types

  • Hello,

    I’m having a problem getting the pagination appearing for my custom post types. Here is the code I have so far:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    			$args = array(
    				'post_type' => 'newsletter',
    				'posts_per_page' => 10,
    				'orderby'=> 'menu_order',
    				'paged'=>$paged
    				);
    			$loop = new WP_Query( $args );
    			custom_query_posts();
    			while ( $loop->have_posts() ) : $loop->the_post();
    				echo '<div class="newsletterExcerpt">';
    				echo '<h2>';
    				the_title();
    				echo '</h2>';
    				echo '<div class="entry-content">';
    				the_excerpt();
    				echo '<div class="entry-content-border"></div>';
    				echo '</div>';
    				?>
    				<a href='<? the_permalink() ?>'>Read more →</a>
    				<?
    				echo '</div>';
    			endwhile;
    			?>
    			<div class="navigation">
            		<div class="alignleft"><?php previous_posts_link('&laquo; Previous') ?></div>
            		<div class="alignright"><?php next_posts_link('More &raquo;') ?></div>
            	</div>

    and in functions.php the function custom_query_posts() is as follows:

    function custom_query_posts(array $query = array()){
        global $wp_query;
        wp_reset_query();
        $paged = get_query_var('paged') ? get_query_var('paged') : 1;
        $defaults = array(
            'paged'             => $paged,
            'posts_per_page'    => PER_PAGE_DEFAULT
        );
        $query += $defaults;
        $wp_query = new WP_Query($query);
    }

    I’ve been looking at this for awhile but just can’t seem to figure it out.

    So any help appreciated.

    Regards,
    Stephen

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Pagination with custom post types’ is closed to new replies.
Skip to toolbar