Support » Themes and Templates » Paging of custom post types

  • bananasontoast


    First I do a loop to output the first 6 items that are of type “portfolio”.

    	// This first line doesn't seem to work, it always seems to return 1 when echoed out
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	$loop = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => 6, 'caller_get_posts'=>1, 'paged' => $paged));
    	while ( $loop->have_posts() ) : $loop->the_post();
    	$custom = get_post_custom($post->ID);
    	$screenshot_url = $custom["screenshot_url"][0];
    	$website_url = $custom["website_url"][0];

    Here I do some stuff to output the items…

    <?php endwhile; ?>

    Then do the paging links for next and previous – this part doesn’t work…

    <div class="navigation">
      <div class="alignleft"><?php previous_posts_link('« Previous') ?></div>
      <div class="alignright"><?php next_posts_link('More »') ?></div>

    So to recap…

    1. The statement using get_query_var(‘paged’) isn’t working
    2. The previous_posts_link and next_posts_link links are not working either
  • The topic ‘Paging of custom post types’ is closed to new replies.