Here is a simple example of what I am wanting to figure out.
Say I have WordPress set to show 5 posts per page. And say I there is a post 17 posts back chronologically.
The formula would be 17 / 5 = 3.4. Round up 3.4 to a whole page of 4 and that post 17 posts back is on the 4th index page.
Now... How to do this programmatically...
The number of posts on each index page is determined by the get_option( 'posts_per_page' );
option.
If all I have is the post's id, how do I figure out how many posts back it is chronologically?
My head first went to WP_Query
, but it is not a suitable option. The blog this is for has thousands of posts and it runs out of memory before I can get anywhere to determine where the post is at.
Does anyone have an clever suggestions?