WordPress.org

Ready to get started?Download WordPress

Forums

Pagination with custom post types (5 posts)

  1. stephen_connolly
    Member
    Posted 1 year ago #

    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

  2. hotwebideas
    Member
    Posted 1 year ago #

    Stephen, I may be missing it, but I do not see the code that shows the pagination links in either code snippet. I see the previous and next links, but are you asking about the numbered page links?

    Bruce

  3. stephen_connolly
    Member
    Posted 1 year ago #

    Yes, I want the numbered links. But I would settle for previous & next links at the moment, as I can't even get them to work.

  4. keesiemeijer
    moderator
    Posted 1 year ago #

    Why are you using the custom_query_posts function?

    Maybe this will help: http://codex.wordpress.org/Pagination#Troubleshooting_Broken_Pagination

  5. stephen_connolly
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic