Skip to content

Commit 85fc517

Browse files
committed
Fix issue with Prev. Post link
1 parent f755dd2 commit 85fc517

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Block/Post/View/NextPrev.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ public function getPrevPost()
8282
$collection = $this->_getFrontendCollection()->addFieldToFilter(
8383
'publish_time', [
8484
'gteq' => $this->getPost()->getPublishTime()
85-
]
86-
);
85+
])
86+
->setOrder('publish_time', 'ASC')
87+
->setPageSize(1);
88+
8789
$post = $collection->getFirstItem();
8890

8991
if ($post->getId()) {
@@ -105,8 +107,10 @@ public function getNextPost()
105107
$collection = $this->_getFrontendCollection()->addFieldToFilter(
106108
'publish_time', [
107109
'lteq' => $this->getPost()->getPublishTime()
108-
]
109-
);
110+
])
111+
->setOrder('publish_time', 'DESC')
112+
->setPageSize(1);
113+
110114
$post = $collection->getFirstItem();
111115

112116
if ($post->getId()) {

0 commit comments

Comments
 (0)