I created a page for my custom post types. The code can be viewed on Snippi: http://snippi.com/s/e8852rx
I’m trying to insert paginate_links, but for whatever reason it’s simply not showing up. Here is the paginate_links code (this code works on normal archive.php files):
<?php
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) );
?>
The following works for me (I’ve removed all the formating / custom post meta).
I would add, its not clear why you need to use a page with a custom template, and don’t instead create a template called archive-portfolio.php
which is used for a custom post type’s archive pages (see template hierarchy)
<?php
/*
Template Name: Portfolio
*/
?>
<?php get_header(); ?>
<div id="container">
<div id="portfolio_content">
<div id="portfolio_wrap">
<?php $loop = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => get_option('to_count_portfolio'), 'paged' => get_query_var('paged') ? get_query_var('paged') : 1 )
); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<span class="title"><?php the_title(); ?></span></br>
<?php endwhile; ?>
<?php
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $loop->max_num_pages
) );
?>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>