I am using a custom page template for my portfolio. The code is calling the correct number of posts per page but for some reason the pagination links won’t show up :-S
My query
<?php
$loop = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => 2));
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php
$custom = get_post_custom($post->ID);
$screenshot_url = $custom["screenshot_url"][0];
$website_url = $custom["website_url"][0];
?>
The entire markup
<?php
/*
Template Name: Portfolio
*/
?>
<?php get_header(); ?>
<div id="full_container">
<div id="portfolio_content">
<div id="portfolio_wrap">
<div id="content">
<?php
$loop = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => 2));
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php
$custom = get_post_custom($post->ID);
$screenshot_url = $custom["screenshot_url"][0];
$website_url = $custom["website_url"][0];
?>
<a href="<?php the_permalink() ?>">
<span class="img">
<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'thmb-portfolio' ); } ?>
<span class="under">
<!-- Excerpt title -->
<span class="title"><?php the_title(); ?></span>
<!-- Excerpt description -->
<span class="desc">
<?php my_excerpt('short'); ?>
</span>
</span>
</span>
</a>
<?php endwhile; ?>
<!-- Next/Previous Posts -->
<?php if (function_exists("pagination")) {
pagination($additional_loop->max_num_pages);
} ?>
</div>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
I don’t see the variable
$additional_loop
being set anywhere in your code. If you’re comfortable with WP-Pagenavi, install it and modify your code as follows:Replace the following:
With:
Hope this helps!