Forums

'same day' navigation link on single.php? (3 posts)

  1. Anointed
    Member
    Posted 2 years ago #

    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?

  2. Anointed
    Member
    Posted 2 years ago #

    to be clear...

    I will create a new function using above code as example, to place a 3rd link on the single page called 'same day'.

  3. Anointed
    Member
    Posted 2 years ago #

    bumping. Hoping someone can chime in on how to pull articles from same date. Looked through codex, but no luck so far

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.