i am using a navigation below the article content with the code below.
This works fine when articles are published on the same day.
But if there is a difference in the publishing date which is larger than one day, no prevoious/next articles are displayed.
Example:
Article 1 is published on the 1st of january
Article 2 is published on the 2nd of januar<
Navigation works fine.
Article 3 is pubblished on the 10th of january
No prev/next navigation
Any suggestions to improve the code, that make the navigation work when there are no articles published for example 5 days?
Thanks
Ralf
Code: Select all
<?php
$previousPageKey = $page->previousKey();
$previousPage = buildPage($previousPageKey);
$nextPageKey = $page->nextKey();
$nextPage = buildPage($nextPageKey);
echo'<div style="float: right;">';
echo '<p>Nächster Beitrag: <br/> ';
if ($page->nextKey()) {
echo'∙ <a href="'.$nextPage->permalink().'">'.$nextPage->title().'</a>';
} else {
echo 'Dies ist der letzte Beitrag.';
}
echo'</p>';
echo'</div>';
echo'<div style="float: left;">';
echo '<p>Vorheriger Beitrag: <br/> ∙ ';
if ($page->previousKey()){
echo'<a href="'.$previousPage->permalink().'">'.$previousPage->title().'</a>';
} else {
echo ' Keine weiteren Beiträge.';
}
echo'</p>';
echo'</div>';
?>