• Anointed

    (@anointed)


    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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Anointed

    (@anointed)

    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’.

    Thread Starter Anointed

    (@anointed)

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

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘‘same day’ navigation link on single.php?’ is closed to new replies.