I have several thousands of posts, that I import using the CSV Importer. During my imports I’ve subsequently been setting the timestamp on some of the posts to the same date.
This works fine inside the loop, which displays all of them in the right order.
However, when I try and get the previous and next post ID from inside the loop using get_adjacent_post … :
$previous_ID = get_adjacent_post(TRUE, "", FALSE)->ID;
… i don’t get the posts that have the same timestamp. So lets say i have 5 images in a category and want to get the Next and Prev ID (which the code above is an example of), I could get just 4 images returned.
Imagine these 5 posts:
Post 1: Publish date: 2011-01-01 12:00
Post 2: Publish date: 2011-01-01 13:00
Post 3: Publish date: 2011-01-01 13:00
Post 4: Publish date: 2011-01-01 14:00
Post 5: Publish date: 2011-01-01 15:00
Using get_adjacent_post() to get the previous post from within post 3 would return the ID for post 1, and not post 2.
I had to build up an array of ID’s on my own to bypass this problem, but this has to be a bug in get_adjacent_post() / get_next_post() / get_previous_post() … ?
- The topic ‘get_adjacent_post doesn't work due to timestamps’ is closed to new replies.