Forum

Thread tagged as: Problem, Blog

Bug in perch_blog_custom when matching by 'lt'

Perch 2.8.13

Using the following code I expect a single post that has a postDateTime < current post to display:

$postData = perch_blog_custom(array(
    'filter' => 'postSlug',
    'match' => 'eq',
    'skip-template' => true,
    'value' => perch_get('s'),
));

$postDateTime = $postData[0]['postDateTime'];

$prevPost = perch_blog_custom(array(
    'count' => 1,
    'filter' => 'postDateTime',
    'match' => 'lt',
    'sort' => 'postDateTime',
    'sort-order' => 'DESC',
    'template' => 'blog/post_prev.html',
    'value' => $postDateTime,
), true);

However, this returns the current post.. (the expected behaviour with a match value of 'lte'). This code used to function as intended, and Drew documented the same approach to displaying prev/next links in Blog here.

Adding 'paginate' => false and 'start' => 2 to the above code works as a workaround, but paginate is absent from the docs for perch_blog_custom so this was difficult to track down.

Brad Cerasani

Brad Cerasani 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What are the values of the two datetimes in this example?

2015-10-10 00:00:00 & 2015-10-11 00:00:00

Drew McLellan

Drew McLellan 2638 points
Perch Support

That should be pretty clear cut. I'll take a look into it.

Thank you.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I can't reproduce this at all. Is there anything more I should be aware of?

Drew McLellan

Drew McLellan 2638 points
Perch Support

We're still having no luck reproducing this. I'm going to close the bug until it turns up in the wild again and we can observe it.