Aug 19, 2010
The Wordpress blog I'm building is published like a magazine; the first day of every month, several (nine, to be exact) posts are published in rapid succession. When a reader views one of these nine posts, the other 8 posts should appear in the sidebar.
View 1 Replies
I have a function I've written to accomplish this, but I'm having some issues that I'll describe below. Here's the code:
$ret = array();
$parent = get_post($post_id, ARRAY_A);
$sdate = strtotime($parent['post_date']);
$month = date('m',$sdate);
The parameter passed to this function is the ID of the post being displayed, so I need to retrieve all of the other posts published during the same month and year as the post being viewed. Wordpress doesn't generate any errors in any of this (nor does PHP, for that matter), but I simply get an empty result set and I'm unsure why that is. The code is fairly straightforward, but if I can clarify anything, do comment and let me know.
Oh, and I've tried adjusting the 'numberposts' parameter and that doesn't seem to have any effect. Also, each post has exactly one category.