Ticket #2415: prev_next_post hooks.diff

File prev_next_post hooks.diff, 2.1 KB (added by majelbstoat, 6 years ago)

Adds hooks to get_previous_post and get_next_post.

  • C:/Xampp/htdocs/development/subversion/wordpress/wp-includes/template-functions-links.php

     
    250250                $join .= ')';  
    251251        } 
    252252 
     253        $join = apply_filters('prev_next_post_join', $join); 
     254        $where = apply_filters('prev_next_post_where', ''); 
     255 
    253256        $sql_exclude_cats = ''; 
    254257        if ( !empty($excluded_categories) ) { 
    255258                $blah = explode(' and ', $excluded_categories); 
     
    261264                $posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')'; 
    262265        } 
    263266 
    264         return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join WHERE post_date < '$current_post_date' AND post_type = 'post' AND post_status = 'publish' $posts_in_ex_cats_sql ORDER BY post_date DESC LIMIT 1"); 
     267        return @$wpdb->get_row("SELECT ID, post_title FROM $wpdb->posts $join WHERE post_date < '$current_post_date' AND post_type = 'post' AND post_status = 'publish' $posts_in_ex_cats_sql $where ORDER BY post_date DESC LIMIT 1"); 
    265268} 
    266269 
    267270function get_next_post($in_same_cat = false, $excluded_categories = '') { 
     
    282285                } 
    283286                $join .= ')';  
    284287        } 
     288         
     289        $join = apply_filters('prev_next_post_join', $join); 
     290        $where = apply_filters('prev_next_post_where', ''); 
    285291 
    286292        $sql_exclude_cats = ''; 
    287293        if ( !empty($excluded_categories) ) { 
     
    296302 
    297303        $now = current_time('mysql'); 
    298304         
    299         return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_type = 'post' AND post_status = 'publish' $posts_in_ex_cats_sql AND ID != $post->ID ORDER BY post_date ASC LIMIT 1"); 
     305        return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_type = 'post' AND post_status = 'publish' $posts_in_ex_cats_sql AND ID != $post->ID $where ORDER BY post_date ASC LIMIT 1"); 
    300306} 
    301307 
    302308