I purchased the Nuke theme and added a custom page template using the code from page.php as a framework. The only code I added was a loop to pull 5 posts from category ID 12. I would like to add navigation buttons “Next and Previous” to view the rest of my posts in this category. What code do I need to add?
View an example of custom page layout : http://www.bodys.co.za/diets-recipes/healthy-recipes/
View code of custom page layout : http://www.bodys.co.za/1.jpg or view code below
<?php
/**
* Template Name: Diets & Recipes
* Page template for Diets & Recipes
*
* @package WordPress
*/
/**
* Get Current page object
**/
$page = get_page($post->ID);
/**
* Get current page id
**/
$current_page_id = '';
if( isset( $page->ID ) ) {
$current_page_id = $page->ID;
}
$page_style = get_post_meta($current_page_id, 'page_style', true);
$page_sidebar = get_post_meta($current_page_id, 'page_sidebar', true);
if( empty( $page_sidebar ) ) {
$page_sidebar = 'Page Sidebar';
}
$caption_class = "page_caption";
if( empty( $page_style ) ) {
$page_style = 'Fullwidth';
}
$add_sidebar = FALSE;
if( $page_style == 'Right Sidebar' ) {
$add_sidebar = TRUE;
$page_class = 'sidebar_content';
} else {
$page_class = 'inner_wrapper';
}
get_header();
?>
<br class="clear"/>
<!-- Begin content -->
<div id="content_wrapper"<?php if( !$add_sidebar ) { ?> class="full_page_width"<?php } ?>>
<div class="inner">
<?php if( !$add_sidebar ) { ?>
<?php pp_breadcrumbs(); ?><br/>
<div class="<?php echo $caption_class; ?>">
<div class="caption_inner">
<h1 class="cufon page_header"><span><?php the_title(); ?></span></h1>
</div>
</div>
<?php } ?>
<!-- Begin main content -->
<div class="inner_wrapper">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php if($add_sidebar) { ?>
<div class="sidebar_content page_sidebar">
<?php } else { ?>
<div class="fullwidth">
<?php
}
?>
<?php pp_breadcrumbs(); ?><br/>
<?php if( $add_sidebar ) { ?>
<div class="<?php echo $caption_class; ?>">
<div class="caption_inner">
<h1 class="cufon sidebar_page_header"><span><?php the_title(); ?></span></h1>
</div>
</div>
<?php } ?>
<?php do_shortcode( the_content() ); ?>
<?php
$args = array( 'numberposts' => 5, 'category' => 12,);
$postslist = get_posts( $args );
foreach ( $postslist as $post ) : setup_postdata( $post ); ?>
<div>
<h6>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</h6>
<div class="post_detail">
<?php echo get_the_time( 'F j, Y', get_the_ID() ); ?>
</div>
<div class="img_nofade2 alignleft">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( 'single-post-thumbnail' ); ?></a>
</div>
<?php the_excerpt(); ?>
</div>
<?php endforeach; ?>
<br />
<div class="clear"></div>
</div>
<?php endwhile; ?>
<?php
if($add_sidebar)
{
?>
<div class="sidebar_wrapper">
<br class="clear"/>
<div class="sidebar">
<div class="content">
<ul class="sidebar_widget">
<?php dynamic_sidebar( $page_sidebar ); ?>
</ul>
</div>
</div>
<br class="clear"/>
<div class="sidebar_bottom"></div>
</div>
<?php
}
?>
</div>
<!-- End main content -->
<br class="clear"/><br/>
</div>
</div>
<!-- End content -->
<br class="clear"/>
<?php get_footer(); ?>
Try using this for you page links.
Maybe you could consider using a plugin to display other posts with a certain post_type / category in a widget area.
This plugin is very useful with all its options:
WordPress ⺠WP Category Post List Widget « WordPress Plugins
It will allow a much more attractive way to lure viewers to click on other posts of that type.