I am trying to modify my 'previous' navigation link to use in another spot on my single.php page to show articles from 'same day'
function get_prev_post_by_sermon($link="« %link", $title="%title") {
global $wpdb, $post;
$prev = $wpdb->get_row($wpdb->prepare("SELECT ID, post_title FROM $wpdb->posts WHERE post_type='xyz' AND post_status='publish' AND post_date < '".$post->post_date."' ORDER BY post_date DESC LIMIT 1;"));
if($prev) {
$title = preg_replace('/%title/',$prev->post_title, $title);
echo preg_replace('/%link/', '<a href="'.get_permalink($prev->ID).'" rel="prev">'.$title.'</a>', $link);
}
}
No matter what I try to add to the post_date portion, I can't seem to come up with a parameter to return values for the same day.
Is there a wp function for this?