Custom post type archive pagination

Community Forums Forums General Discussion Custom post type archive pagination

This topic is: not resolved

This topic contains 3 replies, has 3 voices, and was last updated by  hortonsart 1 year, 9 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #86068


    I’m building a custom post type archive very similar to the Portfolio type in most Studiopress themes. I made the archive page very similar to the archive page in the Executive theme for example (does not use a custom loop).

    How can I get pagination on this archive page so that when a user goes to he/she sees the latest X portfolio posts but also a link to goto the previous X portfolio posts (pagination)?



    Are you just wanting to display x number of portfolio posts per page? Here’s what I’m using for pagination in functions.php:

    /** Change the number of portfolio items to be displayed (by Bill Erickson) */
    add_action( 'pre_get_posts', 'CPT_portfolio_items' );
    function CPT_portfolio_items( $query ) {
        if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'CPT_portfolio' ) ) {
            $query->set( 'posts_per_page', '9' );

    This will display the number of posts specified and then have a “Next Page>>” link for pagination at the bottom of the page


    Au Coeur

    I am having trouble with this too. I have a query as follows:

    function be_art_query( $query ) {
      if( $query->is_main_query() && !is_admin() && ( is_post_type_archive( 'art' ) || is_tax( 'art-type' ) ) ) {
    		$query->set( 'posts_per_page', 12 );
    		$query->set( 'orderby', 'title' );
    		$query->set( 'order', 'ASC' );
    		$query->set( 'post_type', 'art' );
    add_action( 'pre_get_posts', 'be_art_query' );

    It does everything that it should as far as limiting the number of posts, order, etc., but it does not automatically add the next/previous page links (so essentially, in this example, and posts above 12 would be lost).

    Mother. Web & Graphic Designer. Lactation Consultant. Blogging about how it all fits together, most recently from northern Colorado. Visit my blog or my design site.



    Au Coeur, Do you have a link I can look at?

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.