May 20th, 2006 at 11:49pm
I have finally gotten around to fixing the problem with the “Most Recent Posts” list on the “single post and comments” pages, where posts scheduled for the future would appear in the list, and clicking on the link to them would give you a “404 page not found” error.
Here is what the list looked like on Saturday night before the change.
Here is what it looked like after the change.
Notice that a bunch of posts are no longer listed…those posts were, at time of the pictures, scheduled for the future.
The problem was caused by an oversight in the “Blix” theme coded by Sebastian Schmieg where he didn’t take into account WordPress’ ability to schedule posts. You see, to schedule a post you have to specify a time in the future for it to appear and then click “Publish” once you are happy with the post.
This changes the post’s status from “draft” to “published” in the database, which means that WordPress may show it to you on the blog.
The WordPress dashboard shows a list of recent posts and scheduled posts
This is acheived through code which checks the timestamp of the posts with the current time…much like the blog pages do. Here is the code for the recent posts:
And here is the code for the scheduled posts:
If you look carefully you will notice that the main difference (other than adding time until post appears to the scheduled posts) is that the “recent posts” section looks for timestamps “< " (less than) the current time, whilst the "scheduled posts" section looks for timestamps ">” (greater than) the current time.
The “variable” $today is defined near the top of this particular PHP script (multiple PHP scripts make up most pages both on the admin interface of WordPress, and on the public blog side of things).
So here is the code for the “Most Recent Posts” section of the sidebar, I have highlighted the code which I added from the “dashboard”.
Entry Filed under: Blog News