我购买了Nuke主题,并使用页面中的代码添加了一个自定义页面模板。php作为框架。我添加的唯一代码是一个循环,从类别ID 12中提取5个帖子。我想添加导航按钮“Next and Previous”(下一步和上一步),以查看我在该类别中的其他帖子。我需要添加什么代码?
查看自定义页面布局示例:http://www.bodys.co.za/diets-recipes/healthy-recipes/自定义页面布局的视图代码:http://www.bodys.co.za/1.jpg 或查看下面的代码
<?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(); ?>