Paging Custom Page Template
-
I have a custom page which pulls only a single category of posts, I now have enough postings on that page that the previous and next entries links appear at the bottom of the page, however when you follow these links you get the same postings, here is the original page followed by some changes I tried to implement.
original code
<?php
/*
Template Name: Events
*/
?><?php get_header(); ?>
<div id=”content” class=”narrowcolumn”>
<?php
query_posts(‘page_id=’.$_GET[‘page_id’]);
$more = 0;
?><?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class=”post”>
<h2 id=”post-<?php the_ID(); ?>”>” rel=”bookmark” title=”Permanent link to <?php the_title();?>”><?php the_title(); ?></h2>
<div class=”entry”>
<?php the_content(‘Read more »’); ?>
</div>
<p class=”postmetadata”>
<?php edit_post_link(‘Edit’,”,’ | ‘); ?>
<?php
//comments_popup_link(‘ Leave A Comment »’, ‘1 Comment »’, ‘% Comments »’);
?>
</p>
<?php trackback_rdf(); ?>
</div>
<?php endwhile; ?>
<?php endif; ?><?php
$query= ‘cat=11’; // concatenate the query
query_posts($query); // run the query
$more = 0;
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php require(‘post.php’); ?>
<?php endwhile; ?><div class=”navigation”>
<div class=”alignleft”><?php posts_nav_link(”,”,’« Previous Entries’) ?></div>
<div class=”alignright”><?php posts_nav_link(”,’Next Entries »’,”) ?></div>
</div><?php else : ?>
<h2 class=”center”>Not Found</h2>
<p class=”center”><?php _e(“Sorry, but you are looking for something that isn’t here.”); ?></p>
<?php include (TEMPLATEPATH . “/searchform.php”); ?><?php endif; ?>
</div>
<div id=”sidebar” style=”vertical-align:top;”>
<div id=”pages_nav”>
<div style=”margin-left:25px;”>
<?php if(function_exists(“wp_pages_nav”)) {
wp_pages_nav(“current=69&sort_column=menu_order&show_parents=0&show_children=1&depth=2”);
} ?>
</div><div id=”divArchives”>
<h3>Archives</h3>
<?php wp_get_archives(‘type=monthly&limit=12’); ?>
<?php //get_calendar(); ?>
</div></div>
</div>
<?php get_footer(); ?>
changes….
query_posts($query_string);
$more = 0;and
$query= ‘page_id=’.$_GET[‘page_id’];
if($_GET[‘paged’] != ”){
$query=$query . ‘&paged=’ . $_GET[‘paged’];
}
query_posts($query);
$more = 0;code changes did not alter the output
- The topic ‘Paging Custom Page Template’ is closed to new replies.