The theme I am using 'one-theme' looks nice but there is a major problem with it. When a user clicks the 'older' button, for listing older articles not displayed on the homepage, pagination, the next pages show up but you still have the same template file used for the older pages.
In other words, you are still presented with the feature article and featured categories above the older articles. This really confused the readers because they think they are on the same page enless they scroll down the page.
What do I modify in the code below to have wordpress change the template page for all the 'older' pages?
thnx
function ot_paginate() {
// Some info
global $paged;
$on_page = intval($paged);
$no_prev = false;
$no_next = false;
// Fix page
if ($on_page == 0) {
$on_page = 1;
}
// Get the max number of pages
global $wp_the_query;
$max_pages = $wp_the_query->max_num_pages;
// Are we near the start?
$start_pos = $on_page - 2;
if ($start_pos <= 0) {
$amt_from_zero = ($start_pos * $start_pos) + 1; // to account for 0
$start_pos = 1;
}
// Are we near the end?
$end_pos = $on_page + 2;
if ($end_pos >= $max_pages) {
$amt_from_end = $end_pos - $max_pages;
$end_pos = $max_pages;
}
// How does this affect the range?
if (isset( $amt_from_zero ) && isset( $amt_from_end )) {
// Leave them both alone
}
elseif(isset( $amt_from_zero )) { // try and add the remainder on to the end_pos
$end_pos = $end_pos + $amt_from_zero;
if ($end_pos >= $max_pages) {
$end_pos = $max_pages;
}
}
elseif(isset( $amt_from_end )) { // try and subtract the remainder from the start_pos
$start_pos = $start_pos - $amt_from_end;
if ($start_pos <= 0) {
$start_pos = 1;
}
}
// Sort out next and prev
if (($on_page - 1) <= 0) $no_prev = true;
if (($on_page + 1) > $max_pages) $no_next = true;
// How many pages do we have?
$links_to_print = ($end_pos - $start_pos) + 1;
// print the list
echo '<div id="pagination">' . "\n";
echo '<ul>' . "\n";
echo '<li class="extreme"><a href="' . clean_url(get_pagenum_link(1)) . '">«</a></li>';
echo $no_prev ? '<li class="inactive">' . ot_lang( 'newer' ) . '</li>' : '<li><a href="' . clean_url(get_pagenum_link($on_page - 1)) . '">' . ot_lang( 'newer' ) . '</a></li>';
for ($i = $start_pos; $i <= $end_pos; $i++) {
if ($i == $on_page) {
echo '<li class="active">';
} else {
echo '<li>';
}
echo '<a href="' . clean_url(get_pagenum_link($i)) . '">' . $i . '</a></li>';
}
echo $no_next ? '<li class="inactive">' . ot_lang( 'older' ) . '</li>' : '<li><a href="' . clean_url(get_pagenum_link($on_page + 1)) . '">' . ot_lang( 'older' ) . '</a></li>';
echo '<li class="extreme"><a href="' . clean_url(get_pagenum_link($max_pages)) . '">»</a></li>';
echo '</ul>' . "\n";
echo '</div>' . "\n";
}